protected Summary The protected keyword modifies access. If a member is declared protected, it can be accessed from within the class/module it was declared and from any subclasses or submodules. Syntax protected member Parameters member The member to make 'protected'. Description The protected keyword is an access modifier. It is used to change the visibility and access privilege for a member. For classes, if a class member is declared protected, it can be accessed from within the class it was declared and all subclasses, inner classes, and nested classes. For modules, if a module member is declared protected, it can be accessed from within the module it was declared and all children/submodules. Examples Protected Field 1234class Foo{ protected int bar = 1;} Protected Method 1234567class Foo{ protected int bar() { return 1; }} Protected Submodule 123456module Foo{ protected module Bar { }} See Also class module Share HTML | BBCode | Direct Link