Looking for ruby Answers? Try Ask4KnowledgeBase
Looking for ruby Keywords? Try Ask4Keywords

Ruby Language Creating an Array with the literal constructor [ ]


Example

Arrays 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]]