Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

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

by hippo (Chancellor)
on Oct 28, 2020 at 21:19 UTC ( #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
Node Status?
node history
Node Type: note [id://11123282]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (3)
As of 2021-01-22 02:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Notices?