Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re^2: Code blocks with ternary operator or trailing conditionals

by puterboy (Scribe)
on Feb 09, 2014 at 15:36 UTC ( [id://1074131]=note: print w/replies, xml ) Need Help??


in reply to Re: Code blocks with ternary operator or trailing conditionals
in thread Code blocks with ternary operator or trailing conditionals

Indeed, I have tried these in the past -- but:
1. The 'and' method requires one to be very careful about return values -- making sure you have the logic right the first time and that the logic never changes or has exceptions (as you and others have pointed out).
2. The comma method is great (and even works with the ternary operator, if you use parentheses similar to how you did when using 'and'). However, this only works with scalar statements and can create real issues/confusion with operators that can operate on lists (like print).

So thanks for showing these options -- even though I have mostly shied away from them -- due to the syntax/grammer issues you and others have raised. Thanks!!!
  • Comment on Re^2: Code blocks with ternary operator or trailing conditionals

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (3)
As of 2024-04-20 04:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found