On Sunday, 22 June 2014 at 19:58:38 UTC, Kapps wrote:
In theory, 'with' could be used for that if it returned the expression passed in:
auto a = with(new Person()) {
    Name = "Bob";
    Age = 27;
}

You forgot a semicolon after the } ... or at least that's what I think it would need.

I kinda really like this. You could also do things like:

    auto bob = with(PersonBuilder()) {
        name = "Bob";
        age = 27;
    }.build();

with a `with` expression, to make it transactional instead. This could do a lot of neat things, for sure.

Reply via email to