3 ms·
>Wouldn’t I still have to check for NoScore? That's right, and the compiler will reject programs where you don't do this. It's a set of safety rails for your
by brobinson 4y ago
>Wouldn’t I still have to check for NoScore?
That's right, and the compiler will reject programs where you don't do this. It's a set of safety rails for your code. You pay a dev-/compile-time cost in exchange for your programs not exploding at runtime.
- nailer 4y agoYes but that’s no less work than checking for null in TypeScript. The parent said: > In your example, you still have to manually check if there's a value every time, but this is not compiler-enforced.
- brobinson 4y agoSure, it's the same amount of work, but you're forced to do it and the compiler will be able to reject invalid programs. In languages that allow null (including TS, it doesn't 100% enforce the stuff that Haskell, etc. does), you can skip that check, saving some work I suppose, at the risk of your code exploding at runtime. Having stack traces which jump across 50,000 lines of code because someone forgot to check for null somewhere sucks a lot.
- nailer 4y agoTS wouldn’t let you skip that check though.