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

Re: Re: Re: variable set to 0 ? 0 : 1

by jdporter (Paladin)
on Nov 05, 2002 at 15:39 UTC ( [id://210481]=note: print w/replies, xml ) Need Help??


in reply to Re: Re: variable set to 0 ? 0 : 1
in thread variable set to 0 ? 0 : 1

I agree with sauoq.

But here's how I usually write the ternary operator when clarity is a goal:

return $status == 0 ? 0 : 1;
Yes, it seems unnecessarily expansive for this simple case... but I probably wouldn't do it for this simple case.

I would, and do, do this for situations such as:

return @things = $obj->get_current_list_of_things() ? grep /$wanted/, @things : $obj->default_things; # o.k., it's a contrived example. gimme a break.
Predicate and two lemmas, each on its own line.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (4)
As of 2024-04-25 17:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found