Is it possible to restrict number to a certain range

If You have small range, you can always write something like:

type MyRange = 5|6|7|8|9|10

let myVar:MyRange = 4; // oops, error :)

Of course it works just for integers and is ugly as hell 🙂

Leave a Comment