On Monday, 30 November 2015 at 07:58:43 UTC, Andrew LaChance wrote:


Oh interesting. So you are saying I could have a struct WhiteKey {...} and then an enum that extends WhiteKey?

enums can't *extend* anything. You can do this:

struct WhiteKeyS {
    immutable int halfStepsToPrevious;
    immutable int halfStepsToNext;
}

enum WhiteKey {
    A = WhiteKeyS(2, 2),
    B = WhiteKeyS(2, 1),
    C = WhiteKeyS(1, 2)
}

void main() {
    import std.stdio;
    writeln(WhiteKey.A.halfStepsToPrevious);
}

Reply via email to