onsa
2/11/2017 - 9:04 PM

Enums

Enums

//  define enum
enum Direction {X, Y, Z};

function getSpeed (scalarSpeed: number, direction: Direction) {                 //  use enum in parameter definition
  return scalarSpeed + ' km/h in direction ' + direction;
}

//  call function with enum parameter
getSpeed(35, Direction.X);