Skip to content

Instantly share code, notes, and snippets.

@corecode
Last active August 29, 2015 13:57
Show Gist options
  • Save corecode/9872999 to your computer and use it in GitHub Desktop.
Save corecode/9872999 to your computer and use it in GitHub Desktop.
2.0.0-p247 :021 > class A;end
=> nil
2.0.0-p247 :022 > class B<A;end
=> nil
2.0.0-p247 :023 > A.class_variable_get(:@@f)
NameError: uninitialized class variable @@f in A
from (irb):23:in `class_variable_get'
from (irb):23
from /home/2/.rvm/rubies/ruby-2.0.0-p247/bin/irb:16:in `<main>'
2.0.0-p247 :024 > A.class_variable_set(:@@f, 1)
=> 1
2.0.0-p247 :025 > B.class_variable_get(:@@f)
=> 1
2.0.0-p247 :026 > B.class_variable_set(:@@f, 2)
=> 2
2.0.0-p247 :027 > A.class_variable_get(:@@f)
=> 2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment