What is the difference between private and protected methods?

Technology CommunityCategory: RubyWhat is the difference between private and protected methods?
VietMX Staff asked 3 years ago

A private method can only be called by any instance methods of the defining class or any subclasses and must be invoked in a functional style and not explicitly on self such as with self.my_method. A protected method may be explicitly invoked by any instance of the defining class, and is not restricted to implicit invocation on self.