in reply to Re: if/unless and chaining
in thread if/unless and chaining

unless( state equals A ) { Take action1 } elsunless( state equals B ) { Take action2 } else { Take action3 }
the middle line is the same as
elsif (state != B) ...
I agree, don't do that. But not every chain of if/elses is a simple switch statement. I can be testing a number of variables or aspects of the total state, making successively tighter constraints. Think of an && chain with side-effects on each test.

Replies are listed 'Best First'.
Re: Re: Re: if/unless and chaining
by Anonymous Monk on Nov 06, 2002 at 20:23 UTC
    I may be wrong about this, but I think that the example above logically doesn't make sense. The second conditional statement, elseunless(state equals B) will only be reached if the first conditional is true, i.e. state equals a. Effectively the second test will never be true, because when the state equals b, action 1 will be taken.