Hi
Was coding when I recalled this little hack which I would like to share with you.
In other programming languages you can have get and set in the same method as shown below.
Was coding when I recalled this little hack which I would like to share with you.
In other programming languages you can have get and set in the same method as shown below.
Code:
. mata mata clear . mata: : class demo > { > private: > real scalar value > public: > get_set_value() > } : : function demo::get_set_value(|real scalar value) > { > if (value == .) return(this.value) > else this.value = value > } : : d = demo() : // Set value : d.get_set_value(4) : // Get value : d.get_set_value() 4 . end
Comment