in reply to Re: Better solution for code reduction?
in thread Better solution for code reduction?

I'd stared at this option a long time, and finally had to write out the truth table to fully see that this is not the same as the conditions originally put forth.

Original code truth table: wfsp's code truth table: Condition1 Condition2 Execute Condition1 Condition +2 Execute ---------- ---------- ----------- ---------- --------- +- ----------- True True Block1 True True + Block1 True False Block2 True False + Block2 False True Block2 False True + none False False Block2 False False + Block2
Also, since Block2 seems, in this generic example, to be the more important block of code, the unless form of the statement helps point that out (as I'd used in my original reply above)...

-Scott

Replies are listed 'Best First'.
Re^3: Better solution for code reduction?
by wfsp (Abbot) on Mar 11, 2005 at 07:28 UTC
    5mi11er++

    I'd stared at this option a long time...

    So did I - but not long enough!

    Thanks for straightening it out.

    John

Re^3: Better solution for code reduction?
by Anonymous Monk on Mar 11, 2005 at 09:32 UTC
    And even if the second line was fixed so the truth tables would match, it's still wrong. The problem is that if the first set of conditions is true, Block1 will be run, before the second set of conditions is tested. However, running block1 may well change the true/false value of the second set of conditions.

    So it could not be the "generic solution" the OP was looking for.