in reply to Re: Re: if/unless and chaining
in thread if/unless and chaining
unless { second_condition or $matched_already } { do_something_else}
and so on. . . Granted you won't get the nifty optimizations that come with the if/elsif/else structure where the subsequent elsif/else conditions are checked only if the previous if/elsif conditions all failed, but no extra parens. But for the same reasons you stated ..
Reversing the Real Stuff would mean changing ands to ors and inverting whatever, and is easy to mess up
, I think the elsunless would be another layer of complexity that I for one would have to stop the flow of code flowing from the fingers to grab a piece of paper to be able to gather figure what exactly I was excluding in every case, in all but the simplest cases where I would have used the unless/else or if/elsif/else structure anyhow. Then again at the moment I am hard pressed to think of one instance (I have pondered this for a couple of hours already), where an unless/elsunless/else structure would be more natural than its if/elsif/else counterpart. (though, I guess like most logic is a subjective matter)
-enlil
|
|---|