Classes
The concept of creating instances of classes with access to member variables and methods is common across languages.
Create a class with class start
. It takes in, at the very least, the name of the class (in PascalCase as with functions). You can then also provide extends
and a name of a class to indicate a single class to inherit from.
End it with class end
.
In C#:
In Python:
Constructors
Constructors, or initialization methods, are called when a new instance of a class is created. It's declared with constructor start
, which takes the publicity of the constructor, the name of the class, and any number of (name, type) arguments, and constructor end
.
Inherited classes that define a constructor must provide an additional base
argument along with any parameters to call to their parent class' constructor.
In C#:
In Python:
This
You can pass a reference to the current class using the this
command.
In C#:
this
In Python:
self
New
Create new instances of classes with the new
command. It takes in the name of the class and any number of arguments to pass to the parameter.
In C#:
Noun fruit = new Noun("apple");
In Python:
fruit = Noun("apple")
Exports
You can export classes from the current file by including the export
keyword before the class' name.
In C#:
In Python:
Last updated