Project

General

Profile

Bug #12862

Updated by shyouhei (Shyouhei Urabe) over 3 years ago

Loading development environment (Rails 4.2.5) 

 ``` 
 irb(main):001:0> /\$(?<dollars>\d+)\.(?<cents>\d+)/ =~ "$3.67" 
 => 0 
 irb(main):002:0> dollars 
 => "3" 
 ``` 

 


 BUT: 

 ``` 
 irb(main):001:0> numbers = '\d+' 
 => "\\d+" 
 irb(main):002:0> /\$(?<dollars>#{numbers})\.(?<cents>\d+)/ =~ "$3.67" 
 => 0 
 irb(main):003:0> dollars 
 NameError: undefined local variable or method `dollars' for main:Object 
 ```

Back