Ruby uses square brackets to delimit an array.
You can create an array, fill it with some comma-delimited values, and assign it to a variable:
arr = ['one','two','three','four']
Ruby arrays are objects. They are defined by the Array class and indexed from 0.
You can reference an item in an array by placing its index between square brackets.
If the index is invalid, nil is returned:
arr = ['a', 'b', 'c'] puts(arr) # shows 'a' puts(arr) # shows 'b' puts(arr) # shows 'c' puts(arr) # nil # from w w w .j a v a 2 s .c o m