in reply to Re: Ternary if versus normal if question
in thread Ternary if versus normal if question
Why shouldn't you? Perl idiom says that:
(.5<rand) or die "horribly";
is acceptable. In fact even encouraged. Can you explain to OP and others why your very compact and easily read example is so much worse than:
if (.5<rand) { print "Wow\n"; } else { die "horribly"; }
Granted, were the string in either case much bigger, or were more lines of code required than shown in either case, if starts to look much better. Even better however would be the or die idiom.
However, this doesn't really apply to OP's context where $var = <cond> ? <case 1> : <case 2>; is ok and $var = ! $var; is much better.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Ternary if versus normal if question
by blazar (Canon) on Nov 18, 2005 at 07:53 UTC |