Hi
When building classes in Mata it seems like one needs to instantiate the class before setting it's properties (see example coord below which works).
There is a constructor (new) but as the documentation says it can't take any arguments.
I would like to do it like in class coord2 below where instantiation and setting of properties is done in 1 line.
Is this possible?
When building classes in Mata it seems like one needs to instantiate the class before setting it's properties (see example coord below which works).
There is a constructor (new) but as the documentation says it can't take any arguments.
I would like to do it like in class coord2 below where instantiation and setting of properties is done in 1 line.
Is this possible?
Code:
cls mata mata clear mata describe class coord { real scalar x, y void setup() } void coord::setup(real scalar x, y) { this.x = x this.y = y } xy = coord() xy.setup(1, 2) xy.x xy.y class coord2 { real scalar x, y void new() } void coord2::new(real scalar x, y) { this.x = x this.y = y } xy2 = coord2(1, 2) xy2.x xy2.y end
Comment