In ruby ββa private method is simply one that cannot be called with an explicit receiver, that is, with anything to the left of . , an exception was not made for self , except when using setter methods (methods whose name ends with = )
To eliminate the ambiguity of calling a non setter method, you can also use parens, i.e.
my_id()
For a private setter method, i.e. if you have
def my_id=(val) end
then you cannot force ruby ββto parse this as a method call by adding parens. You must use self.my_id= for ruby ββto parse this as a method call - this is an exception to "you cannot call setter methods with an explicit receiver"
source share