From: ptkwt@...1.aracnet.com (Phil Tomson) Date: 2002-09-15T03:25:44+09:00 Subject: Re: not grasping the method overloading/multi-dispatch thing In article <3b3ad3b4.0209132239.2ceb8d91@posting.google.com>, Patrick May wrote: >I just got a better idea for RHDL: > class Signal > def call > proc{self.to_s}.call > end > #.... > def assign_at (relTime=0,nextValue=Proc.new) > nextValue = nextValue.call if nextValue.respond_to? :call > > @eventQueue[relTime] = nextValue > nextValInQueue = @eventQueue.shift > @next_value = nextValInQueue if nextValInQueue > end > > def assign(nextValue=Proc.new) > assign_at(0,nextValue) > end > #.... > end > >2 changes: >* made the common function call, so you don't have to change Proc >* made function.call a guard, so that you don't have to change Object > >This is kind of cheating, since I'm checking some type. Well, you're only checking if nextValue responds to call which is a lot better than the case statement that was there before... >But this is >why I like Ruby giving a way to do so, even if I don't prefer it :-) Thanks for looking at this, I'll give it a try. Phil