dblack / superlink.net writes:

>   your_robot.quack if your_robot.respond.to?("quack")

> The thing that bothers me about the explicit respond_to? test is the need
> to type everything twice.  But I've never come up with a way around that,

class Object
  def senduck(method, *args)
    send(method, *args) if respond_to?(method)
  end
end

class DuckTest
  def quack
    puts "quack, quack!"
  end
end

s = "Hey, I'm a string, don't expect me to quack, I'll just ignore you!"
t = DuckTest.new

s.senduck :quack
t.senduck :quack



:-)