In article <A326C393-C8F2-48B7-92D6-71BB216A9C55 / grayproductions.net>,
  James Gray <james / grayproductions.net> writes:

> I'm just curious, why does this work:
>
>    $ ruby_dev -ve 'if /(?<a>.)/ =~ "abc"; puts a end'
>    ruby 1.9.0 (2008-09-27 revision 0) [i386-darwin9.5.0]
>    a
>
> but not this:
>
>    $ ruby_dev -ve 'if "abc" =~ /(?<a>.)/; puts a end'
>    ruby 1.9.0 (2008-09-27 revision 0) [i386-darwin9.5.0]
>    -e:1:in `<main>': undefined local variable or method `a' for  
> main:Object (NameError)
>
> I'm not complaining.  I'm just trying to understand why this decision  
> was made.

/(?<a>.)/ =~ "abc" is a special syntax which is not overridable.
"abc" =~ /(?<a>.)/ is a normal method call which is overridable.
-- 
Tanaka Akira