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:
Class Foo
' public by default
Field i:Int
Protected
Field someProtectedThing:Int
Method doSomething()
Print "Doing something"
End
Private
Field _somePrivateThing:String
End