On Oct 25, 2007, at 1:40 AM, Robert Klemme wrote:

> Both range versions come in handy, for example, if you need to  
> iterate through an array using an index counter then the triple dot  
> is convenient because you do not need to to math:
>
> for i in 0...ar.size
>   puts ar[i]
> end
>
> #times is an alternative here
>
> ar.size.times do |i|
>   puts ar[i]
> end

 >> letters = (0..9).map { |i| (?a + i).chr }
=> ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j"]
 >> letters.each_index do |i|
?>   puts letters[i]
 >> end
a
b
c
d
e
f
g
h
i
j
=> ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j"]

James Edward Gray II