4 ms·
false-y values in dynamically typed languages is a mistake
by smegsicle 3y ago
false-y values in dynamically typed languages is a mistake
- nine_k 3y agoComing from Python, I find empty collections being falsey very convenient.
- durumu 3y agoI feel like typing len(...) is not that bad, compared to how verbose "default if var_to_test is None else var_to_test" is (compared to "var_to_test or default"). But I agree it is nice -- I wish Python had the ?? operator.
- viraptor 3y agolen() may be either expensive or not possible to calculate for some collections where an emptiness check is trivial. For example a proxy for results from some paged API where you hold the first page initially. Empty check is immediate, len() may take hours.
- smegsicle 3y ago(implicitly converting strings to numbers is pretty convenient too but that doesn't mean php made the right call)