Ternary
Ternary
Code
if apple_stock > 1
:eat_apple
else
:buy_apple
end
Can be converted to
apple_stock > 1 ? :eat_apple : :buy_apple
Source
Default nil case
Nil coalescing stuff in ruby for giving a default value.
x = value || "default_if_value_is_nil_or_false"
x = nil_value || "default"
SO
doc