Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- enum Tree<T> {
- Node(a:Tree<T>, b:Tree<T>);
- Leaf(x:T);
- }
- ...
- switch (sometree) {
- case Node(Node(Leaf(x), Leaf(y)), z): // matches against a tree whose left-subtree is a tree with two leaves (whose data is put in x/y), and whose right side can be anything (put in z)
- default:
- }
- or with consts like:
- switch (keycode) {
- case Keyboard.Left:
- case Keyboard.Right:
- ..
- }
- where Keyboard.Left/Right has to be marked as 'inline static' so that compiler knows it is a constant value that can never change and is interpreted the exact same as:
- switch (keycode) {
- case 72:
- case 48:
- ...
- }
- for whatever value the keycode consts have.
Advertisement
Add Comment
Please, Sign In to add comment