Robert Klemme wrote:

>"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".
>
>  
>
You are right, it doesn't
But I already  manage to make String.str_replace (case sensitive) and 
String.str_ireplace (incase sensitive) pass all my unit test
I already check there is not same function yet build in Ruby object
Thanks a lot for giving me some idea

regards
Eko

>>>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
>
>  
>