Coming from a Python background, where there is always a \"right way to do it\" (a \"Pythonic\" way) when it comes to style, I\'m wondering if the same exists for Ruby. I\'v
The style guide states, that you shouldn't be using return
on your last statement. You can still use it if it's not the last one. This is one of the conventions which the community follows strictly, and so should you if you plan to collaborate with anyone using Ruby.
That being said, the main argument for using explicit return
s is that it's confusing for people coming from other languages.
A common heuristic for method length (excluding getters/setters) in java is one screen. In that case, you might not be seeing the method definition and/or have already forgotten about where you were returning from.
On the other hand, in Ruby it is best to stick to methods less than 10 lines long. Given that, one would wonder why he has to write ~10% more statements, when they are clearly implied.
Since Ruby doesn't have void methods and everything is that much more concise, you are just adding overhead for none of the benefits if you go with explicit return
s.