Skip to content

Instantly share code, notes, and snippets.

@domitry

domitry/hoge.txt

Created Feb 22, 2015
Embed
What would you like to do?
[39] pry(main)> module Hoge
[39] pry(main)* module ClassMethods
[39] pry(main)* def hoge
[39] pry(main)* @@hoge = 1
[39] pry(main)* end
[39] pry(main)* end
[39] pry(main)* def self.included(cls)
[39] pry(main)* cls.extend ClassMethods
[39] pry(main)* end
[39] pry(main)* end
=> nil
[40] pry(main)> class Ni
[40] pry(main)* include Hoge
[40] pry(main)* hoge
[40] pry(main)* end
=> 1
[41] pry(main)> class Ni
[41] pry(main)* @@hoge
[41] pry(main)* end
NameError: uninitialized class variable @@hoge in Ni
from (pry):167:in `<class:Ni>'
[42] pry(main)> class << Ni
[42] pry(main)* @@hoge
[42] pry(main)* end
(pry):170: warning: class variable access from toplevel
NameError: uninitialized class variable @@hoge in Object
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment