An Array is a sequential collection of items in
which each item can be indexed.
In Ruby, (unlike many other languages) a single Array
can hold items of mixed data types such as strings,
integers and floats or even a method-call
which returns some value:
a1 = [1,'two', 3.0, array_length(a0)]
a1[0] # returns 1st item (at index 0) a1[3] # returns 4th item (at index 3)
In common with many other programming languages,
Ruby uses square brackets to delimit an array.
You can easily create an array, fill it with some
comma-delimited values and assign it to a variable:
arr = ['one','two','three','four']
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[0]) # shows a‟ puts(arr[1]) # shows b‟ puts(arr[2]) # shows c‟
puts(arr[3]) # nil