Skip to content

Instantly share code, notes, and snippets.

@eee-c
Created June 4, 2009 12:35
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 eee-c/123595 to your computer and use it in GitHub Desktop.
Save eee-c/123595 to your computer and use it in GitHub Desktop.
bash$ irb
>> class Foo; @@foo = :foo; class << self; def inside_foo; @@foo; end end end
=> nil
>> class << Foo; def outside_foo; @@foo; end end
=> nil
>> Foo.inside_foo
=> :foo
>> Foo.outside_foo
(irb):2: warning: class variable access from toplevel singleton method
NameError: uninitialized class variable @@foo in Object
from (irb):2:in `outside_foo'
from (irb):4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment