| Author: | j |
|---|---|
| Mode: | text |
| Date: | Fri, 6 Aug 2010 00:49:55 |
procedure match;
[T] overload match(x:T, static T, fn, ...etc) = ...fn(x);
[T, U | T != U] overload match(x:T, static U, fn, ...etc) = ...match(x, ...etc);
variant Foo = Int | Float;
foo(x) {
match(*x,
Int, lambda(x) { println("I saw an Int ", x); },
Float, lambda(x) { println("I saw a Float ", x); }
);
}