ANN: Matchable 0.2

http://matchable.rubyforge.org/

The Matchable mixin borrows ideas from ML
http://www.smlnj.org/sml97.html(and
probably other functional languages).
The syntax currently supported looks like this:

class Bar
include Matchable
def_match(:plus, nil, nil){|a,b| a+b}
def_match(:plus, String, nil){|a,b| “#{a}:=>#{b}”}
def_match(:plus, /hello/, nil){|a, b| “hello world”}
end

b = Bar.new
=> #Bar:0xb758e7ac
b.plus(5,5)
=> 10
b.plus(“five”,5)
=> “five:=>5”
b.plus(“hello”, 5)
=> “hello world”

class Foo
include Matchable
def test(tuple)
case tuple
when mcase([:test, 5, 5]) then “poop”
when mcase([:test, nil, nil]) then “whoop”
when mcase([nil, nil]) then “hoot”
else “foot”
end
end
end