On Saturday, 8 December 2018 at 04:11:03 UTC, Murilo wrote:
What is the difference between declaring "int a = [1,2,3];" and declaring "int a = [1,2,3];"? Is the first an array and the second a range?
They are both arrays, just the former one has a fixed size and the latter does not. Ranges require a way to iterate and consume elements, meaning they cannot be fixed size.
I always thought that leaving the square brackets empty would create an array of flexible size, it never occurred to me that it was creating something else.
That's what it is, just a flexible array also happens to be an array, whereas a fixed-size array is not one.
But a slice of a fixed size one yields a flexible one.. which is why the ps thing works to create a range out of it.