Skip to content

Instantly share code, notes, and snippets.

@arthurnn
Created May 20, 2016 14:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arthurnn/8789b3a891a16f93e6817630b7f5ec23 to your computer and use it in GitHub Desktop.
Save arthurnn/8789b3a891a16f93e6817630b7f5ec23 to your computer and use it in GitHub Desktop.
Constant leaking on class_eval
[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