Just another Ruby on Rails weblog

Ruby method access levels: protected and private

ruby

Good example which illustrate the difference between protected and private methods in Ruby:

• Protected methods can be invoked only by objects of the defining class and its subclasses. Access is kept within the family.
• Private methods cannot be called with an explicit receiver—the receiver is always self. This means that private methods can be called only in the context of the current object; you can’t invoke another object’s private methods. (c) PickAxe.

mitjok

Читайте також:

  • No related posts found.

Коментувати