Is there a way to implement method overloading in ruby? Naively I
just
defined two methods with the same name with different number of
parameters...Ruby didn't like that.
Donglai
<shameless plug>
The StrongTyping module on RAA lets you do this:
def foo(*args)
overload(args, String) {
...
return ...
}
overload(args, String, String) {
...
return ...
}
...
overload_default args
end
Of course, if you don't care what type of object you want
specifically, you can just say "Object", and you can specify multiple
types like [String, NilClass].
</shameless plug>
--
Ryan Pavlik <
[email protected]>
"Ye don't like me? But we don't even know each other. I
bets we have a lot in common. Treachery and such. Yar." - 8BT