3 ms·
These are easy questions. 1. If you convert a string which has non-numbers to an integer, an error is raised 2. Truthiness should not exist as a concept. Just
by darthrupert 6y ago
These are easy questions.
1. If you convert a string which has non-numbers to an integer, an error is raised
2. Truthiness should not exist as a concept. Just booleans and expressions that evaluate to booleans.
PHP's backwards compatibilty promise makes these more difficult questions, of course.
- pavlov 6y agoEasy questions but not obvious answers. What kind of error to raise? Do you return a NaN? Throw an exception? Both have their uses.
- darthrupert 6y agoThrow a standard exception. E.g. python calls it a ValueError. Returing NaN is clearly wrong design.
- Erlich_Bachman 6y ago> 2. Truthiness should not exist as a concept. Meh, it's actually quite useful in many situations.