Tuesday, March 10, 2009

Arrays

An array is a list in Ruby. For example...

names = ['Max', 'Nancy', 'Lazy']

puts names(0)
puts names(1)
puts names(2)
puts names(3) #This is out of point

Anyway, if you don' t understand why names(3) is out of point, Ruby actually counts from 0. It will return 'nil' if you go out of point.

There' s lots of variables in arrays. I couldn't tell you all, so I' m going to quit this post now...

No comments: