2012/8/4  <sto.mar / web.de>:
>
> It should work (without typo):
>
> 1.9.3p194 :001 > '<test>'.gsub!(/>/, '&lt;').gsub!(/</, '&gt;')
>  => "&gt;test&lt;"

Nope.

irb(main):001:0> 'test'.gsub!(/>/, '&lt;').gsub!(/</
NoMethodError: undefined method `gsub!' for nil:NilC
        from (irb):1
        from F:/Ruby193/bin/irb:12:in `<main>'

#gsub! (with bang) modifies the receiver and returns nil if no changes
were made.

#gsub (without bang) always returns a new string.


-- Matma Rex