On Tuesday, 2 June 2020 at 09:28:01 UTC, realhet wrote:
static foreach(k, v; fieldMap){ mixin("@property auto $() const{ return #; }".replace("$", k).replace("#", v)); } //I know, i know -> AliasSeq :D
You can use std.format.format to do it in one function call:mixin("@property auto %s() const { return %s; }".format(k, v));
Or just put `k` and `v` directly into the mixin: mixin("@property auto ", k, "() const { return ", v, "; }");