4 ms·
At least have an honest comparison: function render() { $return = null; if($condition1 && $condition2) $return = 2; elseif($condition1) $r
by hxa7241 14y ago
At least have an honest comparison:
function render() {
$return = null;
if($condition1 && $condition2) $return = 2;
elseif($condition1) $return = 1;
elseif($condition3) $return = 3;
else $return = 4;
return $return
}
- bwh2 14y agoI was comparing what I frequently see vs what I'd like to see. Your example code is pretty rare in my experience. So I think the comparison is pretty fair.
- VMG 14y agoAnother example r = 0; outer: { foreach (x in a) { foreach (y in b) { if (condition(a, b)) { r = 1; break outer; } } } return r; instead of foreach (x in a) { foreach (y in b) { if (condition(a, b)) { return 1; } } } return 0;
- deleted 14y ago[deleted]