Always include parenthesis when it clearly aids in code readability and omit when it doesn't add clarity.
def foo bar
string = "hello from foo method"
bar #omit return keyword
end
foo "cookie"
def foo(bar)
string = "hello from foo method"
return bar
end
foo("cookie")
Both method defs/calls are acceptable. I prefer the first as parans clutter up code in my opinion and most in the Ruby community would agree. However you use, what you're comfortably with, but just keep it consistent.
bar
is returned no need to use return
keyword. The last statement executed in a method will always be returned.
Links included for further learning:
Ruby Style Guide: https://github.com/styleguide/ruby
Ruby Usage Guide: http://www.caliban.org/ruby/rubyguide.shtml
Neither are official Ruby documents but both can be referenced for general consensus of how to write and format your code as per community preferences.