On Mar 20, 10:15 am, "Mat Schaffer" <scha... / gmail.com> wrote:

<snip>

> In the interest of ridiculousness, how about using the multi gem for
> this? :)
>
> require 'rubygems'
> require 'multi'
>
> class Foo
>   def initialize(*args)
>     multi(:init, Integer) { |i|
>       puts 'integer used'
>       # do integer stuff...
>     }
>
>     multi(:init, Float) { |f|
>       puts 'float used'
>       # do float stuff...
>     }
>
>     init(*args)
>   end
> end

Heh, that interface is very similar to Nobu's overload package. [1]
There's also Ryan's strongtyping package for simulating overloaded
methods. [2]

Regards,

Dan

[1] http://www.rubyist.net/~nobu/ruby/overload-0.6.tar.bz2
[2] http://raa.ruby-lang.org/project/strongtyping/

PS - Nobu, you need to update your RAA link for the overload
package. :)