Ruby Array usage examples

Array usage examples

#!/usr/local/bin/ruby

nums = [1, 2.0, "three", "four"]
puts nums[2]    # index from 0
puts nums[-1]   # wraps around prints "four"

mystuff = %w{tivo nokia ipaq}  # make a string array
puts mystuff 

myarray = [1,2,5,7,11]    
puts myarray          # 1 2 5 7 11 down page
puts myarray.inspect  #[1, 2, 5, 7, 11]
p myarray  #[1, 2, 5, 7, 11]