O
Old Echo
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.
Thanks all,
kodama
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.
Thanks all,
kodama