I\'m learning Ruby, and have come up to a point where I am confused.
The book I am using is talking about private
, public
, and protec
public
methods are open to everyone. As for private
versus protected
, I refer to "Ruby Private Methods vs. Protected Methods":
What is the difference between 'private' and 'protected' methods in Ruby? In Ruby, the primary difference between a 'private' and 'protected' method is that a private method cannot be called with an explicit receiver, while a protected method can. What is an 'explicit receiver', you ask? An explicit receiver is the object that is receiving a message. In the following example, we have a receiver ('parent') and a method ('get_name'). The 'parent' object is receiving the instruction to perform the 'get_name' method.