Ruby/Array/Array Literal
Материал из Wiki.crossplatform.ru
Array with %w
words = %w[this is a test] # Same as: ["this", "is", "a", "test"] open = %w| ( [ { < | # Same as: ["(", "[", "{", "<"] white = %W(\s \t \r \n) # Same as: ["\s", "\t", "\r", "\n"]
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