Constructors
Classes use init to define constructors. A class can define multiple constructors as long as their parameter lists differ (constituting overloading). The function body of a constructor must complete the assignment of all uninitialized instance member variables.
Cangjie also supports primary constructors, whose name is the same as the class name. In the primary constructor's parameter list, you can use let or var to declare member variable parameters, accomplishing both member variable definition and constructor parameter declaration simultaneously.
The Person class below demonstrates two ways of defining constructors. The first init is a regular constructor, and the second is a simplified syntax for primary constructor. Objects created by both approaches behave identically.
If a class has no custom constructor and all member variables have initial values, the compiler will automatically generate a parameterless constructor.
Try adding a third constructor that only accepts a name parameter and defaults age to 0.