Ruby developers try to follow certain code design rules. You do not specify a semicolon at the end of the expression, although this is allowed. You do not specify a return
in the last method expression, although this is allowed.
Regarding parentheses framing method parameters, there is also a rule:
Use def
with parentheses when the method has parameters. Omit brackets when the method takes no parameters.
# плохо def some_method() # некоторый код end # хорошо def some_method # некоторый код end # плохо def some_method_with_parameters param1, param2 # некоторый код end # хорошо def some_method_with_parameters(param1, param2) # некоторый код end
More details on the code design rules can be found here . This is why you see a setter with brackets everywhere — a sign of good Ruby code.