Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class NonZeroNumber {
- constructor(readonly num: number) {
- if (num === 0) throw 'Value cannot be 0';
- }
- }
- function devide(x: number, y: NonZeroNumber) {
- console.log(x / y.num);
- }
- devide(2, new NonZeroNumber(2)); //Yes, man, this is typescript!
- devide(2, {num: 0}); //ahahahahhahahahahahahahahahahahah
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement