From: paul@... (Paul J. Sanchez) Date: 2002-09-13T06:00:59+09:00 Subject: Re: not grasping the method overloading/multi-dispatch thing >>>>> "PT" == Phil Tomson writes: PT> In article <20020912151951.T25425@atdesk.com>, PT> Paul Brannan wrote: >> On Fri, Sep 13, 2002 at 03:40:42AM +0900, Phil Tomson wrote: >>> Currently if we need a method that does two different things >>> based on the type of an argument we have to do: >>> >>> def meth(s) case s when Integer #do something when Float #do >>> something else end end >> This isn't necessary; see Hal's example of another alternative >> (declare a method in the Integer and Float classes that gets >> called from meth(), so that meth() follows the same code path >> for whatever type you use). PT> Good point. >> The downside is that you have to modify those classes in order >> for this to work. >> PT> In Ruby it's not really considered a downside... it seems to PT> be an acceptable practice. What happens when two programmers, working on different pieces of a large project, add different methods with the same name to a base class? --paul