top of page
Class
Classes can be describe the properties and behaviour of a particular entity. A class can be defined in the following way.
​
class <class-name> (
def init (args...) (
...
)
<methods>
)
obj = <class-name> (val1, val2...)
​
The init method is the constructor method which is optional and is automatically called with tuple of values given.
​
class Point (
def init (x, y, z) (
this.x = x
this.y = y
this.z = z
)
)
p1 = Point (1, 2, 3)
​
The this keyword can be used to disambiguate between local variables and fields.
bottom of page