Because you need to initialize it. Otherwise, the compiler believes that you only need the interface of the variable: the getter and setter methods. This is very similar to how a method without a body is abstract. The following initializes it to zero and gives you a valid concrete class with a specific variable.
class Exp { var exp1: Exp = _; }
This use of _ means "default", where the default is null for reference types and 0, false, or something similar for types without a reference.
James ry
source share