It The Ruby Way ™ to not include an operator return, if not required.
I am sure there are better examples, but simple here.
def divide a, b
return false if b == 0
a/b
end
It is worth noting that Ruby provides options for optionally ignoring a lot of syntax. ()are optional if you have not invested them. {}may also be omitted in many cases.
func(5, 5, {:hello => 'world'})
func 5, 5, hello: 'world'
You will recognize many more shortcuts when you go.
maček source
share