Skip to content

Instantly share code, notes, and snippets.

@rentalcustard
Created June 2, 2012 09:05
Show Gist options
  • Save rentalcustard/2857452 to your computer and use it in GitHub Desktop.
Save rentalcustard/2857452 to your computer and use it in GitHub Desktop.
Constant resolution in instance_eval
class A
B = Module.new
def ieval(&block)
instance_eval(&block)
end
end
B = Module.new
p A.new.ieval { B }
Ξ ~ → rvm use 1.8.7
Using /Users/tomstuart/.rvm/gems/ruby-1.8.7-p358
Ξ ~ → ruby test2.rb
B
Ξ ~ → rvm use 1.9.2
Using /Users/tomstuart/.rvm/gems/ruby-1.9.2-p290
Ξ ~ → ruby test2.rb
A::B
@BanzaiMan
Copy link

1.9.3 behaves as 1.8.7 did.

$  ruby -v 1test.rb
ruby 1.9.3p125 (2012-02-16 revision 34643) [x86_64-darwin11.3.0]
B

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment