Search
module Foo def shared 'Foo shared' end def foobar shared end end module Moo def shared 'Moo shared' end def moobar shared end end class Wingnut include Moo include Foo end w = Wingnut.new w.foobar # => "Foo shared" w.moobar # => "Foo shared"
June 4th, 2008
Is this a surprise? Only if you think like Java rather than JavaScript. Self always points to the receiver, and method lookup is LIFO on the module chain.
Not surprising, just notable.
Name (required)
Mail (will not be published) (required)
Notify me of followup comments via e-mail
Website
Enclose code in <code lang="ruby"></code> if you care. Preview your comment using the button below.
Submit Comment
Is this a surprise? Only if you think like Java rather than JavaScript. Self always points to the receiver, and method lookup is LIFO on the module chain.
June 4th, 2008
Not surprising, just notable.
June 4th, 2008