A
Andreas Schwarz
Why do I get an exception? Shouldn't Mod2 have the method return_true
because it included Mod1?
irb(main):001:0> module Mod1
irb(main):002:1> def return_true
irb(main):003:2> true
irb(main):004:2> end
irb(main):005:1> end
=> nil
irb(main):006:0> module Mod2
irb(main):007:1> include Mod1
irb(main):008:1> def self.test
irb(main):009:2> return_true
irb(main):010:2> end
irb(main):011:1> end
=> nil
irb(main):012:0> Mod2.test
NameError: undefined local variable or method `return_true' for Mod2:Module
because it included Mod1?
irb(main):001:0> module Mod1
irb(main):002:1> def return_true
irb(main):003:2> true
irb(main):004:2> end
irb(main):005:1> end
=> nil
irb(main):006:0> module Mod2
irb(main):007:1> include Mod1
irb(main):008:1> def self.test
irb(main):009:2> return_true
irb(main):010:2> end
irb(main):011:1> end
=> nil
irb(main):012:0> Mod2.test
NameError: undefined local variable or method `return_true' for Mod2:Module