Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
epidemian
GitHub Repository: epidemian/gravity
Path: blob/master/test/computed_properties.gravity
1214 views
#unittest {
	name: "Computed properties.";
	result: 700;
};

class foo {
	private var _a = 12;
	var a {
		set {_a = value * 100;}
		get {return _a/2;}
	};
}

func main() {
	var f = foo();
	f.a = 14;		// 14*100 = 1400
	return f.a;		// 1400/2 = 700
}