On Wednesday, 25 September 2019 at 19:25:06 UTC, Ali Çehreli
wrote:
On 09/25/2019 12:06 PM, WhatMeWorry wrote:
> I was
> assuming that [] meant "the entirety" of the array.
Assuming we're talking about D slices, Yes. (It could be a
user-defined type with surprisingly different semantics.)
> In short, is there anytime that one would want to use
"slice[] =
> something" syntax?I
That changes element values.
Ok. But which element(s)? In my specific case, I was using [].
Is
waste[] = waste[0..$-1];
even semantically meaningful? Because the LDC compiler had no
problem compiling it.
> //waste[] = waste[0..$-1]; // object.Error@(0): Array lengths
don't
> match for copy: 0 != 1
>
> waste = waste[0..$-1]; // works
That makes slice refer to a different set of elements. In that
example, the slice does not include the last element anymore.
Ali