Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: Better expression for $x = !!$y||0

by ghenry (Vicar)
on Apr 19, 2005 at 08:18 UTC ( [id://449141]=note: print w/replies, xml ) Need Help??


in reply to Better expression for $x = !!$y||0

See the Conditional Operator, to understand the above better.

Walking the road to enlightenment... I found a penguin and a camel on the way.....
Fancy a yourname@perl.me.uk? Just ask!!!

Replies are listed 'Best First'.
Re^2: Better expression for $x = !!$y||0
by borisz (Canon) on Apr 19, 2005 at 08:41 UTC
    Thanks all, sure I know about the conditional. It just look unnatural in a if statement to me. Thats why I used || in the first place. But since all answers are more or less the same. I shouldn't be so picky.
    Boris

      Since you don't like seeing the conditional operator in the if, why don't you move it to the outside?

      $x = $y ? 1 : 0; if ($x) { ... }

      It has the added advantage of removing an assignement from an if's condition, something I find quite unnatural and unreadable.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (5)
As of 2024-03-29 10:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found