Encapsulation#
Introduction#
There are three levels of encapsulation for class and struct members:
-
Public
members can be accessed from anywhere. It is the default encapsulation level. -
Protected
members can only be accessed by the base class and the derived ones or by class/struct extensions. Code existing in the same source file have acces toProtected
members too. -
Private
members can only be accessed by the base class. Code existing in the same source file have acces toPrivate
members too.
There is also the Internal
privacy level, used to declare module internal accessibility.
Example:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | Class Foo ' public by default Field i:Int Protected Field someProtectedThing:Int Method doSomething() Print "Doing something" End Private Field _somePrivateThing:String End |