Learn a little bit of Scala's class constructor every day
The class constructors in An and scala are as follows:
Main constructor
Slave constructor
B, main constructor
Parameter list, written after the class name
Main constructor content: the content in the class, except for field definition and method definition, is the content of the main constructor.
C, slave constructor
Class, which begins with def this, is derived from the constructor
The first line of the slave constructor must call the master constructor, or other slave constructors; in fact, it is a restriction that the first line of the slave constructor must be the master constructor, which is the only entry point for the class.