Literals of class
Array
are created by placing a comma-separated
series of object references between square brackets. A trailing comma
is ignored.
arr = [ fred, 10, 3.14, "This is a string", barney("pebbles"), ]
|
Arrays of strings can be constructed using a shortcut notation,
%w
,
which extracts space-separated tokens into successive
elements of the array. A space can be escaped with a backslash.
This is a form of general delimited input,
described on pages 200--201.
arr = %w( fred wilma barney betty great\ gazoo )
|
arr
|
� |
["fred", "wilma", "barney", "betty", "great gazoo"]
|