Ranges
Ali Çehreli
acehreli at yahoo.com
Fri Aug 5 15:06:00 UTC 2022
On 8/5/22 01:59, frame wrote:
> On Thursday, 4 August 2022 at 22:14:26 UTC, Ali Çehreli wrote:
>
>> No element is copied or moved. :)
>>
>> Ali
>
> I know that :)
And I know that. :) We don't know who else is reading these threads, so
I didn't want to give wrong impression.
Copying would happen if we added slicing on the left-hand side. However,
I realized that the following fails with a RangeError:
void main() {
auto arr = [1, 2, 3];
arr[0..$-1] = arr[1..$]; // <-- Runtime error
}
I suspect the length of the array is stamped too soon. (?)
Should that operation be supported?
Ali
More information about the Digitalmars-d-learn
mailing list