coding style: single line method definitions #10

Open
riffraff opened this Issue Sep 19, 2011 · 1 comment

Comments

Projects
None yet
2 participants

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 :)

Owner

weppos commented Sep 20, 2011

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment