Type inference and overloaded functions
bearophile
bearophileHUGS at lycos.com
Wed Dec 11 17:09:34 PST 2013
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. I am not sure but I
Think arr2 data is allocated on the stack. It looks a little
confusing, but I think it contains a rule we can learn.
Bye,
bearophile
More information about the Digitalmars-d-learn
mailing list