Quick question. Is there more elegant way to write something like this?
result = a <=> b
if result == 1
# do something
elsif result == 0
# do something else
else
# do something else
end
Quick question. Is there more elegant way to write something like this?
result = a <=> b
if result == 1
# do something
elsif result == 0
# do something else
else
# do something else
end
You can use the
case
statement:For simple one liners you can also shorten it with
then