From: Sebastian Hungerecker Date: 2008-11-15T20:07:17+09:00 Subject: Re: how to call operator as function Vladimir Fekete wrote: > operators = { "+" => Fixnum.+, > "-" => Fixnum.-, "+" => Fixnum.instance_method(:+), "-" => Fixnum.instance_method(:-), >               "++" => Myclass.++} There is no ++ operator in ruby and you can't define one. > op = "+" > > result = operators[op](left,right)  if left.class==Fixnum and > right.class==Fixnum result = operators[op].bind(left).call(right) if left.is_a?(Fixnum) and right.is_a?(Fixnum) Or you skip the whole thing with the hash and just do: op = "+" result = left.send(op, right) HTH, Sebastian -- Jabber: sepp2k@jabber.org ICQ: 205544826