Several Array literals : Array Literal « Array « Ruby






Several Array literals


x = 1
y = 2
[1, 2, 3]         # An array that holds three Fixnum objects
[-10...0, 0..10,] # An array of two ranges; trailing commas are allowed
[[1,2],[3,4],[5]] # An array of nested arrays
[x+y, x-y, x*y]   # Array elements can be arbitrary expressions
[]                # The empty array has size 0

 








Related examples in the same category

1.Array with %w