Hi,

At Mon, 18 Aug 2003 16:47:47 +0900,
Yukihiro Matsumoto wrote:
> Ah, wait.  If you don't need thread safety, you can do it as:

You forget the trick that you'd written ago.

>   "hello world".gsub(/(\w+)/) { print $1; $1 }; print "\n"
>   class String
>     alias :old_gsub :gsub
>     def gsub(*args, &block)
>       if block
>         old_gsub(*args) {
            eval("proc{|m|$~ = m}", block).call($~)
>           yield $&
>         }
>       else
>         old_gsub(*args, &block)
>       end
>     end
>   end
>   "hello world".gsub(/(\w+)/) { print $1; $1 }; print "\n"

-- 
Nobu Nakada