Array constructor syntax is confusing to both the system and humans. Avoid it when possible.
Consider this..
|
|
Now, let’s say we do the same using a constructor.
|
|
This is ok, but there is a way to use new Array
to specify the number of elements in the array.
|
|
So, if we provide only one input - does it mean the number of elements, or the first element?
|
|
Avoid confusion by avoiding the Array.new()
notation. Use our beloved square brackets to create arrays.