in reply to Re^3: How to Do Multiple OR in For Loops
in thread How to Do Multiple OR in For Loops
If a short circuit effect is wanted, it should be done explicitly.That appears to be saying "if you want the short circuit effects of || and &&, you shouldn't use || and &&, but do it explicitly, but it's ok to use || and && (and get the short circuiting) if you don't want it".
But that would be strange, and it's probably not what you wanted to communicate.
Personally, I very much prefer to write things like:
instead ofif (ref $code && $code->()) {...} # short circuit
It's a long time since I coded Pascal, and I don't miss much of it. Actually, I don't think I miss anything from it.if (ref $code) { if ($code->()) { # explicitly ... } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: How to Do Multiple OR in For Loops
by LanX (Saint) on Apr 13, 2011 at 12:48 UTC |