deltaluca

Untitled

May 3rd, 2013
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Haxe 0.66 KB | None | 0 0
  1. enum Tree<T> {
  2.    Node(a:Tree<T>, b:Tree<T>);
  3.    Leaf(x:T);
  4. }
  5.  
  6. ...
  7.  
  8. switch (sometree) {
  9.    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)
  10.    default:
  11. }
  12.  
  13. or with consts like:
  14.  
  15. switch (keycode) {
  16.    case Keyboard.Left:
  17.    case Keyboard.Right:
  18.    ..
  19. }
  20.  
  21. 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:
  22.  
  23. switch (keycode) {
  24.   case 72:
  25.   case 48:
  26.   ...
  27. }
  28.  
  29. for whatever value the keycode consts have.
Advertisement
Add Comment
Please, Sign In to add comment