Methods ending with = are not ordinary methods, because they are identified by the ruby โโinterpreter as setters and therefore have syntactic sugar:
d.attr = 4
When you call d.attr=() , you actually call d.attr=(()) . () in ruby โโreturns nil :
()
The Ruby interpreter will not let you go without any arguments, because if you drop () at all, ruby โโwill simply take the result of the next line as a parameter or throw syntax error if you try to break the line using ;
d.attr= 5 # => 5 d.attr=; # => syntax error, unexpected ';'
To see your default argument, you can use send :
d.send(:attr=)
source share