From: Robert Klemme Date: 2004-10-25T22:49:07+09:00 Subject: Re: [rcr] String#first / String#last "Florian Gross" schrieb im Newsbeitrag news:2u4cv2F24vocaU1@uni-berlin.de... > Robert Klemme wrote: > > >>| |adding a to_a might be good > >>| "to_a" works line-wise. Perhaps "explode" > >>RCR for #chars > > This does not yield characters but strings with length 1. Note also that > > there is String#each_byte which is often sufficient. > > The problem with String#each_byte is that nobody wants to handle > characters as Integers in Ruby, IMHO. (I think one-character Strings are > preferred, because they still let you use lots of Strings useful methods.) Yeah possibly. Another problem with each_byte is that byte != char for many encodings. But AFAIK #each_byte and #split(//) share this problem. I believe a drawback of using "foo".split(//) is that it's less performant: you need to create the tmp array plus all the string instances (although they share the buffer AFAIK). > > Kind regards > > robert > > More regards, > Florian Gross Even more regards robert :-)