2 ms·
I would write it like this: def my_method if @foo == :bar :foo_matches else nil end end but, hell, you
by philwelch 14y ago
I would write it like this:
def my_method
if @foo == :bar
:foo_matches
else
nil
end
end
but, hell, you wanna see something even cooler?
def my_longer_method
...
variable = if @foo == :bar
:foo_matches
else
nil
end
...
end
I find this much better than ternary operators.