A basic array with [] : Array Creation « Array « Ruby
- Ruby
- Array
- Array Creation
A basic array with []
x = [1, 2, 3, 4]
# This array has four elements.
# Each element is an integer, and is separated by commas from its neighboring elements.
# All the elements are contained within square brackets.
Related examples in the same category