Me and a few friends are trying to learn verse and we are having trouble with the classes. Does anyone know of a good place to learn more in depth about the classes because the quick reference is not very specific. As far as we can tell there is not many ways to protect variables.
Is this what you mean by the quick reference? Class
Here is a link to visibility specifiers in the Verse Glossary
Here is how you do visibility specifiers:
# Class is public in this module
example_class := class<public>():
# Prop is private
Prop1<private>: float = 0.0
# Prop is protected
Prop2<protected>: float = 0.0
# Prop is public (also default)
Prop3<public>: float = 0.0
what’s the difference between <private>
and <protected>
?
Private will disallow access for subclasses as well as the outside world
a := class():
PublicProp<public>: float = 0.0
PrivateProp<private>: float = 0.0
ProtectedProp<protected>: float = 0.0
b := class(a):
Function():void=
ProtectedProp # No Error
PrivateProp # Error
Main():void=
a{}.PublicProp # No Error
a{}.PrivateProp # Error
a{}.ProtectedProp # Error
1 Like