Sea&Gull
2/3/2005 12:11:00 PM
Tom Rathbone wrote:
> Hi,
>
> 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|"
>
>
> #collect_char or #each_char would be great.
"some string".split('').collect {|i| print i, '|'}
>
> Perhaps not the best example there, basically i intend to interpret a
> string of character commands from a string i.e. something like
> Brainf**k.
>
> Thanks,
>
> Tom.
>
>
--
s&g