Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re^3: conditional print. Is correct to use it?

by hippo (Bishop)
on Oct 28, 2020 at 21:19 UTC ( [id://11123282]=note: print w/replies, xml ) Need Help??


in reply to Re^2: conditional print. Is correct to use it?
in thread conditional print. Is correct to use it?

I think kcott is saying that you might, in some conditions, wish to retain the non-empty false value in $x rather than discard it in favour of $y. eg. if 0 were a valid input for $x and you had:

$x = 0; $y = 10; $number = $x || $y; print "$number\n";

You would see 10 rather than the valid-but-false 0. In such cases $number = $x // $y; might be more appropriate.


🦛

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11123282]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (3)
As of 2024-04-19 01:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found