Created
April 20, 2012 13:53
-
-
Save ka8725/2428868 to your computer and use it in GitHub Desktop.
This file contains 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
irb(main):048:0> module P | |
irb(main):049:1> def a; puts 'a'; end | |
irb(main):050:1> module_function :a | |
irb(main):051:1> end | |
=> P | |
irb(main):052:0> P.a | |
a | |
=> nil | |
irb(main):053:0> P::a | |
a | |
=> nil | |
irb(main):054:0> class E | |
irb(main):055:1> include P | |
irb(main):056:1> end | |
=> E | |
irb(main):057:0> E.a | |
NoMethodError: undefined method `a' for E:Class | |
from (irb):57 | |
from /Users/ka8725/.rbenv/versions/1.9.2-p290/bin/irb:12:in `<main>' | |
irb(main):058:0> E.new.a | |
NoMethodError: private method `a' called for #<E:0x007fe06d16cf38> | |
from (irb):58 | |
from /Users/ka8725/.rbenv/versions/1.9.2-p290/bin/irb:12:in `<main>' | |
irb(main):059:0> module Q | |
irb(main):060:1> def a; puts a; end | |
irb(main):061:1> end | |
=> nil | |
irb(main):062:0> class E | |
irb(main):063:1> include Q | |
irb(main):064:1> end | |
=> E | |
irb(main):065:0> E.a | |
NoMethodError: undefined method `a' for E:Class | |
from (irb):65 | |
from /Users/ka8725/.rbenv/versions/1.9.2-p290/bin/irb:12:in `<main>' | |
irb(main):066:0> E.new.a | |
SystemStackError: stack level too deep | |
from /Users/ka8725/.rbenv/versions/1.9.2-p290/lib/ruby/1.9.1/irb/workspace.rb:80 | |
Maybe IRB bug!! | |
irb(main):067:0> E.ancestors | |
=> [E, Q, P, Object, Kernel, BasicObject] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment