Advertisement
Guest User

Untitled

a guest
Feb 23rd, 2019
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.30 KB | None | 0 0
  1. class NonZeroNumber {
  2. constructor(readonly num: number) {
  3. if (num === 0) throw 'Value cannot be 0';
  4. }
  5. }
  6.  
  7. function devide(x: number, y: NonZeroNumber) {
  8. console.log(x / y.num);
  9. }
  10.  
  11. devide(2, new NonZeroNumber(2)); //Yes, man, this is typescript!
  12. devide(2, {num: 0}); //ahahahahhahahahahahahahahahahahah
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement