"E S" <eero.saynatkari / kolumbus.fi> schrieb im Newsbeitrag
news:20050125052315.WKZL2811.fep31-app.kolumbus.fi / mta.imail.kolumbus.fi...

> B) You can use Enumerable:
>
> class String
>   def str_replace(what, with)
>     s = self.collect do |c|
>           with if c === what
>         end
>   end
> end

I don't think this will work as String#each does not yield single
characaters but "lines".

>> a=<<EOS
foo
bar
end
EOS
=> "foo\nbar\nend\n"
>> a.each {|x| p x}
"foo\n"
"bar\n"
"end\n"
=> "foo\nbar\nend\n"
>> a.collect {|x| p x; :x}
"foo\n"
"bar\n"
"end\n"
=> [:x, :x, :x]

Regards

    robert