Tom Werner
9/28/2007 6:49:00 PM
This caused me a small headache the other day. By including a module, an
instance method suddenly becomes accessible as a module method. Seems
unintuitive, I'm curious to understand the reasoning behind it.
module Foo
module Bar
def hello
'hello'
end
end
end
Foo::Bar.hello # => -:9: undefined method `hello' for Foo::Bar:Module (NoMethodError)
include Foo::Bar
Foo::Bar.hello # => "hello"
--
Tom Preston-Werner
* Libraries:
Chronic (chronic.rubyforge.org)
God (god.rubyforge.org)
Fuzed (fuzed.rubyforge.org)
* Site:
rubyisawesome.com