4 ms·
This is also not possible in a dynamic language like Python. The compiler can't check that you're only entering boolean expressions in the if clause, because it
by anon4 13y ago
This is also not possible in a dynamic language like Python. The compiler can't check that you're only entering boolean expressions in the if clause, because it's all dynamically typed. The best alternative is Ruby's "nil and false are the only things that are false". The other option is throwing an exception at runtime if the if clause evaluates to a non-boolean, which strikes me as way too anal.