rubyist
rubyist copied to clipboard
coding style: single line method definitions
I wonder if there is consensus on how/when to use single line method definitions. E.g.
def foo() bar end
vs
def foo; bar; end
It's a small thing, and I'd say it makes sense to point out that usually it's just better to avoi them. Although I write them all the time :)
This is an interesting point.
I personally suggest to avoid one-line definition, even if methods are empty like the case of very simple Rails controllers. The only situation where one-line definitions are allowed is in tests, in case you need to create a class on the fly for specific tests.
I'll add a paragraph to the documentation.