From: zdennis Date: 2006-04-12T18:55:58+09:00 Subject: Re: Style question: if !x vs. unless x -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Logan Capaldo wrote: > > On Apr 12, 2006, at 2:31 AM, David Brady wrote: > >> Oh, wait. By multiconditional unless, you mean stuff like this: >> >> unless ( a || b || c ) >> do_something >> end >> >> ...yes? > > > I'm pretty sure he means: > > unless condition > ... > else > .. > end > > or > > unless condition > ... > elsif othercondition > ... > else > ... > end > I mean what Logan said plus the second half of what Dave said. I do not like the following, and I find it a) sometimes confusing to read and b) my brain has to think twice when reading, which is twice to much: unless condition ... elsif ... else ... end unless cond1 and cond2 and cond3 ... end unless (cond1 and cond2) or cond3 ... end do_something unless cond1 and cond2 In regards to the first half of Dave's email: > > if x > do_something > end unless y > > I do like this syntax, though: > > do_something if condition unless exception > I have never thought of chaining conditionals like that, although the idea is very cool... and I find it readable in the case of error handling. (I wont say exception handling because IMO the two differ and exceptions should be handled by a different mechanism then what error conditions should be handled under, the whole 90/10 rule applies of course.) =) Zach -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.1 (GNU/Linux) Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org iD8DBQFEPM/LMyx0fW1d8G0RAvJgAJwKfktuwgUbcI6iZ+Nd0mVzqxoq5gCeJhoX f7Ygn98m+JdYMPB5ZkrvL4c= =h6ey -----END PGP SIGNATURE-----