in reply to unless....else

I've known that unless ... else ... works for ages, but I don't use it for just the reason you didn't think it would work - it just doesn't sound right. When someone else is reading and maintaining my code I want them to be able to read it quickly and easily, not have to keep going "huh?".

Replies are listed 'Best First'.
Re: Re: unless....else
by graff (Chancellor) on Aug 06, 2003 at 03:21 UTC
Re: Re: unless....else
by bobn (Chaplain) on Aug 06, 2003 at 05:20 UTC

    When I see unless (cond) {code} else {other code}, something wierd happens in my head. I know it works, I know what it does, but I can't get what's happening unless I mentally make it if (not cond) {code} else {other code}. Call me crazy (you won't be the first), but that's how my mind works. (Does this just mean I'm getting old?)

    So since I'm going to do this in my head anyhow, that's how I write it.

    What's strange is that I use it in modifiers all the time, e.g. next unless $_;. No problem for me here.

    --Bob Niederman, http://bob-n.com