2 ms·
> What's terrible about truthy and falsy? Basically it's very error prone. It's difficult to remember the rules which are usually quite complicated which leads
by IshKebab 5y ago
> What's terrible about truthy and falsy?
Basically it's very error prone. It's difficult to remember the rules which are usually quite complicated which leads to mistakes.
Much better just to be explicit.
> How do you even have a language without a definition of what is truthy and what is falsy?
You make it so that `if` only works on `bool` types, and don't implicitly convert other types to `bool`. For example if you want to check if string is non-empty, then you have to do `if (the_string != "") {` rather than `if (the_string) {`, which may cause your code to unexpectedly fail if e.g. the string is "false".