Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> make non-strict comparisons more useful and less error prone, by using a number comparison only if the string is actually numeric. Otherwise the number is converted into a string, and a string comparison is performed.

That… makes it even worse.



why?


Because now the behavior of comparison depends on whether the string looks like a number.


Arguably 48 == "48" should be true. If this doesn't work for you, stick to ===.


Thank you, I'll stick to languages where you can't just compare numbers and strings without an explicit conversion.

Also, should 48 == "48.0" be true? How about "048", "48.", "0x30", " 48 ", "48foo", "3*16", "XLVIII", "forty-eight"?


Once again: just use ===

If you decide languages based on minutiae like this, I can only pity you.


=== works for equality (if you actually remember to use it), but how about comparison? There's no strict version of <.


strcmp




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: