On Fri, 9 May 2003 20:32:58 +0900
KONTRA Gergely <kgergely / mlabdial.hit.bme.hu> wrote:

> Hi!
> 
> There was a thread about a little typechecking to ruby.
> What's the status of this?
<snip>

I wrote a little module for just this.  Check out 'StrongTyping' on
RAA:

    http://raa.ruby-lang.org/list.rhtml?name=strongtyping

You can do this:

    def fn(*args)
        overload(args, String, String) {
            ...
        }
    
        overload(args, Integer, Integer) {
            ...
        }
    
        overload_default args        
    end
    
This dispatches properly on 'args', otherwise gives an error.  You
can also use it on single functions:


    def fn2(a, b, c)
        expect(a, String, b, Symbol, c, String)
        ...
    end

as well as being able to query a function for its types, etc.
HTH,

-- 
Ryan Pavlik <rpav / users.sf.net>

"Why do I even try to share my *fabulous* wit with you?" - 8BT