Created
May 20, 2016 14:40
-
-
Save arthurnn/8789b3a891a16f93e6817630b7f5ec23 to your computer and use it in GitHub Desktop.
Constant leaking on class_eval
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[arthurnn@snowball ~]$ irb | |
irb(main):001:0> class Foo | |
irb(main):002:1> FOO = "foo" | |
irb(main):003:1> end | |
=> "foo" | |
irb(main):005:0> Foo.class_eval { BAR = "bar" } | |
=> "bar" | |
irb(main):006:0> BAR | |
=> "bar" | |
irb(main):007:0> FOO | |
NameError: uninitialized constant FOO | |
from (irb):7 | |
from /Users/arthurnn/.rubies/ruby-github/bin/irb:15:in `<main>' | |
irb(main):008:0> Foo::FOO | |
=> "foo" | |
irb(main):009:0> Foo::BAR | |
(irb):9: warning: toplevel constant BAR referenced by Foo::BAR | |
=> "bar" | |
irb(main):010:0> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment