July 15, 2013 getter/setter in one function (almost) | ||||
---|---|---|---|---|
| ||||
unfortunately, dmd doesn't accept the signature as a valid property. import std.stdio; import std.typecons; struct T { int _i; @property int i(Nullable!int derp = Nullable!int.init) { return _i = derp.isNull ? _i : derp.get; } } void main () { T t; t.i = 1; writeln(t.i); } |
Copyright © 1999-2021 by the D Language Foundation