Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[doc] Perlop: mention best way to get a real 0 #17562

Open
jidanni opened this issue Feb 14, 2020 · 0 comments
Open

[doc] Perlop: mention best way to get a real 0 #17562

jidanni opened this issue Feb 14, 2020 · 0 comments

Comments

@jidanni
Copy link
Member

jidanni commented Feb 14, 2020

Perlop says

   Relational Operators
       Perl operators that return true or false generally return values that can be safely used as numbers.  For
       example, the relational operators in this section and the equality operators in the next one return 1 for
       true and a special version of the defined empty string, "", which counts as a zero but is exempt from
       warnings about improper numeric conversions, just as "0 but true" is.

Perhaps add

If you want a real 0, then add 0 to it.
   print 3 == 3; # 1
   print 3 == 4; # nothing
   print 0 + ( 3 == 4 ); # 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant