From: jogloran Date: 2006-03-21T16:31:39+09:00 Subject: Re: iterate chars in a string ------=_Part_12979_179001.1142926282702 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline The thing I don't like about this behaviour is that an algorithm which operates on containers and expects #each can't work immediately with strings. Daniel Tse On 3/21/06, Robert Dober wrote: > > Mike I really agree, I *was* expecting that behavior from "each" too, som= e > time ago, and it took me some time to figure it out > BTW I think the "nicest" solutions is mine combined with Robert's (pun > intended) > > "Ty Mr. Klemme".each_byte { |b| puts b.chr } > > my "%" stuff was rather clumsy. > > bye for now > Robert > > On 3/20/06, Berger, Daniel wrote: > > > > > -----Original Message----- > > > From: Mike Austin [mailto:noone@nowhere.com] > > > Sent: Monday, March 20, 2006 12:39 PM > > > To: ruby-talk ML > > > Subject: Re: iterate chars in a string > > > > > > > > > "I am puzzled".each_byte { |b| puts b.chr } > > > > > > I'm surprised that not many people knew about 'each_byte()'. > > > Maybe it's a > > > problem with Ruby docs? Or maybe it is just > > > counter-intuitive - I would expect > > > each() iterate over bytes, and provide each_lines() to > > > iterate over lines instead. > > > > > > Mike > > > > > > http://www.rubycentral.com/ref/ > > > > Modifying String#to_a to return an array of characters has been brought > > up before (ruby-talk:148588 and following). I don't think Matz likes > > the idea, though. > > > > Dan > > > > > > > -- > Deux choses sont infinies : l'univers et la b=EAtise humaine ; en ce qui > concerne l'univers, je n'en ai pas acquis la certitude absolue. > > - Albert Einstein > > ------=_Part_12979_179001.1142926282702--