Re:Ifs and &&s and Plan 9's Source Code
by pieguy on Friday May 24, 2013 @04:09PM
(#5764949)
And what's the alternative for if(A && B){ x(); }else{ y(); }? Seems very easy to shoot yourself in the foot with this approach.
[ Parent
| on HN ]
Well, you could
if (one) {
if (two)
if (three)
if (soon) {
stuff
}} else {
else stuff
}
Personally, I think I won't have any trouble reading that, but I have noticed I'm somewhat more tolerant than others in this regard. Though I am more OCD than others in other ways.That doesn't what he's talking about, though. Your else will run anytime `one` is false, not when `one && two && three && soon` is false.
But it's still not the equivalent of: if (one && two && three && soon) {stuff} else {stuff}
which I assume the GP meant.