25 ms·
That's one reason. Another is that it allows you to use the idiom (if X ...) to test for non-null rather than (if (not (null X)) ...)
by lisper 4y ago
That's one reason. Another is that it allows you to use the idiom (if X ...) to test for non-null rather than (if (not (null X)) ...)
- tuukkah 4y agoIndeed, although some languages achieve the same by defining multiple falsy values, e.g. JS has 9 such values: https://developer.mozilla.org/en-US/docs/Glossary/Falsy https://developer.mozilla.org/en-US/docs/Glossary/Falsy
- lisper 4y agoYeah, but this causes its own set of problems when, for example, you are surprised that 0.0 is false but -0.0 is true. In general, punning of any kind is a Really Bad Idea when code gets complicated.