Untitled
unknown
d
2 years ago
564 B
3
Indexable
Never
import std.stdio; import std.variant; public class Blah { private Variant[string] values; alias values this; this() { this.x = 5; } @property Variant opDispatch(string name)() const { return values[name]; } @property void opDispatch(string name, T)(T val) { values[name] = val; } void update() { this.x = this.x + 1; } } void main() { Blah blah = new Blah(); writeln(blah["x"]); writeln(blah.x); blah.update(); writeln(blah["x"]); writeln(blah.x); }