From: Max Muermann Date: 2006-08-25T07:00:50+09:00 Subject: Re: That's Ruby, Virginia! On 8/25/06, William James wrote: > Henry Savr wrote: > > Here it is: > > > > def array_101 > > for i in [0 ... self.length] > > puts "#{i} => #{self[i]}" > > end > > end > > class Array > def array_101 > each_with_index{|e,i| > puts "#{i} => #{e}" > } > end > def array_102 > puts (0...self.size).zip(self).map{|a| a.join(' => ')} > end > end > Much better this way. To fix the original code, use (0..self.length) - note these are not square brackets. Alternatively, you can use (0..10).to_a to turn a range into an array. Max