One thing I love about ruby is that mostly it is a very readable language (which is great for self-documenting code)
However, inspired by this question: Ruby Code ex
I like how If-then-elses or case-when could be shortened because they return a value:
if test>0
result = "positive"
elsif test==0
result = "zero"
else
result = "negative"
end
could be rewriten
result = if test>0
"positive"
elsif test==0
"zero"
else
"negative"
end
The same could be applied to case-when:
result = case test
when test>0 ; "positive"
when test==0 ; "zero"
else "negative"
end