On 12/11/2013 05:09 PM, bearophile wrote:

> Ali Çehreli:
>
>> >      int[] arr2 = [7, 8, 9]s;
>> >      assert(is(typeof(arr2) == int[3]));
>>
>> That looks very confusing. The left-hand side looks like a slice,
>> which I can append elements to but its type is a static array?
>
> No, the type of the literal is of a fixed-side array, but it gets
> assigned to a dynamic array, so it's a slice.

No problem there.

> I am not sure but I Think
> arr2 data is allocated on the stack.

Although important, I wasn't considering that point at all.

> It looks a little confusing, but I
> think it contains a rule we can learn.

But look at the assertion: the type of the *slice* arr2 is int[3]. :)

>
> Bye,
> bearophile
>

Ali

Reply via email to