in reply to Re: Code blocks with ternary operator or trailing conditionals
in thread Code blocks with ternary operator or trailing conditionals
2. Consider using the 'do' statement if the compound statement is still very short and the code will be visually cleaner and easier to read but the operators are non-scalar, so the comma operator can't be used. e.g.,$error = "Bad result", next unless defined $result;
Although, that may not be much better/cleaner than:do{push @results, $item; next} if defined $item;
3. Otherwise use the full-blown if/else alternativeif(defined $item){push @results, $item; next}
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Code blocks with ternary operator or trailing conditionals
by Anonymous Monk on Feb 09, 2014 at 19:32 UTC |