Creating an Array with the literal constructor
suggest changeArrays can be created by enclosing a list of elements in square brackets (\[
and \]
). Array elements in this notation are separated with commas:
array = [1, 2, 3, 4]
Arrays can contain any kind of objects in any combination with no restrictions on type:
array = [1, 'b', nil, [3, 4]]
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents