Guest User

Untitled

a guest
May 7th, 2018
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. public enum Something {
  2.  
  3. PENNY("PENNY"), NICKLE("NICKLE");
  4.  
  5. private String value;
  6.  
  7. private Something (String value) {
  8. this.value = value;
  9. }
  10.  
  11. };
  12.  
  13. export enum ControlType {
  14. INPUT,
  15. SELECT,
  16. DATEPICKER
  17. }
  18.  
  19.  
  20. console.log(ControlType.INPUT); // returns 0
  21. console.log(ControlType[ControlType.INPUT]); // returns INPUT
  22.  
  23. export enum ControlType {
  24. INPUT = 3,
  25. SELECT = 6,
  26. DATEPICKER = "abc".length // computed member
  27. }
  28.  
  29. console.log(ControlType.INPUT); // returns 3
  30.  
  31. export enum ControlType {
  32. INPUT = <any>'input',
  33. SELECT = <any>'select',
  34. DATEPICKER = <any>'date-picker'
  35. }
  36.  
  37. console.log(ControlType.INPUT); // returns 'input'
  38.  
  39. (ControlType.INPUT === myVar) {..}
  40.  
  41. enum Direction { Up, Down, Left, Right }
  42.  
  43. console.info(Direction[Direction.Up]); // "Up"
  44.  
  45. const directionText = new Map([
  46. [Direction.Up, 'UP'],
  47. // ...
  48. ]);
Add Comment
Please, Sign In to add comment