From: Martin DeMello Date: 2004-08-11T05:16:14+09:00 Subject: Re: string.each_char Alexander Kellett wrote: > On Wed, Aug 11, 2004 at 03:21:15AM +0900, Martin DeMello wrote: > > I really think String#each_char ought to be added to the core - it's one > > of the most basic String operations, and in practice a lot more useful a > > default case than each_byte. Sure, I can simulate it in a lot of > > different ways, but I really do think it ought to be there by default. > > what are you attempting to archieve with it? > "string".each_byte { |byte| puts byte.chr if byte == ?s } Iterating over a string letter by letter, without having to do string.split(//).each {} I often find myself using a string as a compact data structure, essentially a C style array of chars, and need to iterate over the letters as an analogue to array#each{}. It feels clumsy to add an extra layer of conversion. martin