Robert Klemme wrote:
> 
> def foo(x)
>   case x
>   when Fixnum
>      self + x
>   when String
>      "You sent: %p" % x
>   else
>     raise NameError, "No overriden version of foo(%p)" % x.class
>   end
> end
> 

I should mention that simple /overloading/ can be achived by delegating 
the action to the 'x':

def foo(x)
  case x
  when Fixnum
     self + x
  when String
     "You sent: %p" % x
  else
     x.foo  # Note this line!
  end
end

Ruby's core library uses this technique in several places.
-- 
Posted via http://www.ruby-forum.com/.