Hacker News new | past | comments | ask | show | jobs | submit login

Perl does the same thing with type coercion, and "0" in Perl is false. However, the thing that Perl does that PHP doesn't is have different operators for strings and numbers.

Don't get me wrong, I think conflating strings and numbers is a bad idea, but if you're going to conflate strings and numbers, then having separate operators is the right thing to do.




I am not very familiar with Perl. When you say different operators for strings and numbers are you referring to something similar to PHP's === operator for which "1"===true would be a false statement?


Perl's numeric equivalence operator is ==, while its string equality operator is eq. Perl's operators are monomorphic that way.


in perl

"==" returns true if the left argument is numerically equal to the right argument.

"eq" returns true if the left argument is stringwise equal to the right argument.

see 'perldoc perlop' under the heading "Equality Operators"




Consider applying for YC's Spring batch! Applications are open till Feb 11.

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

Search: