Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
Ruby
Scope of constants in instance_eval
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
[QUOTE="George Ogata, post: 4506727"] But only in 1.9, if I understand you correctly. g@crash:~/tmp$ cat test.rb class C def initialize &b instance_eval(&b) end X = 2 end C.new{puts eval('X')} g@crash:~/tmp$ ruby -v test.rb ruby 1.8.4 (2005-12-24) [i686-linux] test.rb:8: (eval):1: uninitialized constant X (NameError) from test.rb:3:in `eval' from test.rb:8 from test.rb:3:in `initialize' from test.rb:8 g@crash:~/tmp$ ruby19 -v test.rb ruby 1.9.0 (2006-02-15) [i686-linux] 2 [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
Ruby
Scope of constants in instance_eval
Top