Easy one for you: What's the Ruby equivalent of this in PHP?
return $x == 0 ? 1 : $x;
It's the same
x == 0 ? 1 : x
The ||= shortcut is not applicable here, because 0 is not a "falsy" value, it's true.
||= to work as PHP would too.if is an expression, not a statement (in fact, everything is an expression in Ruby, there are no statements), so the use of the conditional operator is never necessary, and using if is often more readable: if x == 0 then 1 else x end.