From: Calamitas Date: 2008-06-14T21:35:35+09:00 Subject: Re: Modules, Overloading, and some Confusion On Sat, Jun 14, 2008 at 12:48 PM, Old Echo wrote: > Hello Rubyists, > Here's something I've been pondering lately and was hoping to get a good > response from someone out in the community. It's about having two > modules which both implement a method with the same name, and then > including both modules into a class. > > Example: > > module Honda > def start > puts "Wroom" > end > end > > > module Ford > def start > puts "Rrrooom" > end > end > > class Car > include Honda > include Ford > end > > car = Car.new > car.start > => Rrrroooom > > > Okay, so that's a pretty contrived example, but here's my question: how > can I can call the start method defined in Honda rather than the start > method defined in Ford? I feel like there's something I'm missing here, > but I'm not sure what it is. c = Car.new c.start # => Rrrooom Honda.instance_method(:start).bind(c).call # => Wroom Or cleaner: require 'facets' c.as(Honda).start # => Wroom Peter