From: Robert Dober Date: 2006-03-21T06:26:43+09:00 Subject: Re: iterate chars in a string ------=_Part_7690_24384068.1142889986310 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Mike I really agree, I *was* expecting that behavior from "each" too, some 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_7690_24384068.1142889986310--