Tom Rathbone wrote:

> Is there a function that would work over the characters in String in
> the way that each works for an array?  I want to process the string
> character by character and thought that #each would do this,
> apparently not.  Even better would be a collect style method. 
> Something like this.
> 
> "some string".collect do |x|
>    x + '|'
> end
> 
> 
>>>"s|o|m|e| |s|t|r|i|n|g|"

Generally you can do "some string".scan(/./).map { |x| x + "|" }

But note that will construct an intermediate array which is a little 
inefficient -- if you have really big strings (a few hundred kilobyte) 
you're probably better off doing it like this instead:

result = ""; "some string".scan(/./) { |x| result << x << "|" }; result