4 ms·
> Are you suggesting that those working in static languages don't need to write tests? You certainly don't need to write tests that Math.floor will return NaN
by jdmichal 10y ago
> Are you suggesting that those working in static languages don't need to write tests?
You certainly don't need to write tests that Math.floor will return NaN when you pass it something that's not a number...
- kazinator 10y agoWhat? NaN is actually a number in the sense of being in the domain of the floating-point type. You seem to be mixing up "not a number" (as in character string or list) versus "not a number" as in a special IEEE representation that has special uses in numeric code. A floor function that returns NaN when given a string, instead of throwing a type mismatch exception, is crap design, and a strawman example of that type of checking. It's not an appropriate use of NaN!
- jdmichal 10y agoI agree with you [0], but that's what JavaScript gives us to work with. [0] https://news.ycombinator.com/item?id=11898046 https://news.ycombinator.com/item?id=11898046