Method Visibility
There are three types of method visibility:
PublicCallable from anywhere
ProtectedCallable only from instances of the same class
PrivateCallable only in functional form (i.e., without the receiver specified)
Method visibility is defined using the public,
private, and protected methods
in classes and modules.
public([symbol...])Makes the method specified by
symbolpublic. The method must have been previously defined. If no arguments are specified, the visibility of all subsequently defined methods in the class or module is made public.protected([symbol...])Makes the method specified by
symbolprotected. The method must have been previously defined. If no arguments are specified, the visibility of all subsequently defined methods in the class or module is made protected.private([symbol...])Makes the method specified by
symbolprivate. The method must have been previously defined. If no arguments are specified, the visibility of all subsequently defined methods in the class or module is made private.
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access