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

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
  • Comment on Re^2: Better expression for $x = !!$y||0

Replies are listed 'Best First'.
Re^3: Better expression for $x = !!$y||0
by ikegami (Patriarch) on Apr 19, 2005 at 18:53 UTC

    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.