Andrej Mitrovic:

> Good idea / bad idea?

I prefer a solution that to me looks simpler, discussed a bit here:
http://d.puremagic.com/issues/show_bug.cgi?id=3878

With that idea your struct becomes:

struct Foo {
    int a, b, c, d, sum, average;

    this(int this.a, int this.b, int this.c, int this.d) {
        sum = a + b + c + d;
        average = (a + b + c + d) / 4;
    }
}

Bye,
bearophile

Reply via email to