On 12/7/18 11:16 PM, Adam D. Ruppe wrote:
On Saturday, 8 December 2018 at 04:11:03 UTC, Murilo wrote:
What is the difference between declaring "int[3] 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.
I think, you mean "a flexible array also happens to be *a range*..."
-Steve