Exercise
Guess what each of the following expressions will give, then > try them out in irb:
a = [3, 39, 1, 0, 5]
a[1]
a.first
a[0]
a[5]
a[-1]
a[-5]
a.last
a[1..3]
a[1..-1]
b = []
a.empty?
b.empty?
a.length
b.length
a.include?(39)
a.include?(49)
a.reverse
a # has this changed a?
a.reverse!
a # has this changed a?
a.sort
a # has this changed a?
a.sort!
a # has this changed a?
a = [1, 2, 3, 4, 5]
a[3] = 6
a # What is a now?
a[7] = 7
a # What else has been added?
a << 9 # This one's important - you'll see it a lot