From: Joel VanderWerf Date: 2007-10-26T02:28:54+09:00 Subject: Re: Intervals in Ruby James Edward Gray II wrote: > 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"] What was that example meant to show? Must be something other than this: puts ("a".."j").to_a -- vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407