I've been watching a video (YouTube - "Pipeline-oriented programming - Scott Wlaschin - NDC Porto 2023") with something like the following code. This only sets the first method call, so I'm wanting to know how to make this work, for the subsequent methods.
import std;
struct Person {
string name, email;
ulong age;
auto withName(string name) { this.name=name; return this; }
auto withEmail(string email) { this.email=email; return this; }
auto withAge(ulong age) { this.age=age; return this; }
}
void main() {
Person p;
p.withName("Tom").withEmail("joelcnz@gmail.com").withAge(44);
writeln(p);
}