From: Marko Schulz Date: 2002-03-19T21:07:59+09:00 Subject: Re: Wanted: slick rubyesqe algorithm On Tue, Mar 19, 2002 at 01:53:50PM +0900, Guy N. Hurst wrote: > > Here's my contribution: > > a.each_index{|i| if String===a[i] then a[i,2]=a[i]+a[i+1] while String===a[i+1] end} That's nice. I would prefer a little bit more readable version: a.each_index do |i| if String===a[i] a[i,2]=a[i]+a[i+1] while String===a[i+1] end end My eyes are not adapted to Module#===Object either, but if one is used to it, this looks like a nice shortcut to Object#type==Module. I am always a little afraid to modify a structure I am iterating over. Different languages and libraries are differently robust concerning this. Is it generally OK to do this in ruby? -- marko schulz