Encapsulation#
Introduction#
There are three levels of encapsulation for class and struct members:
-
Publicmembers can be accessed from anywhere. It is the default encapsulation level. -
Protectedmembers 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 toProtectedmembers too. -
Privatemembers can only be accessed by the base class. Code existing in the same source file have acces toPrivatemembers 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 |