Consider the following code snippet:
void main() {
Band myBand = new Band();
myBand.guitar();
print("Number of players " + myBand.players.toString());
}
class Rock {
int players=2;
void guitar() {
print('Rock guitar');
}
}
mixin Jazz {
int players=1;
void guitar() {
print('Jazz guitar');
}
}
class Band extends Rock with Jazz {
}
Here I have the class Band which extends Rock and the mixin Jazz. Both have a property and a method of the same name - players
and guitar
.
If I now subclass Band and invoke the guitar
method or query the player property
I get:
Jazz guitar Number of players 1
Obviously for some reason the mixin is of higher importance. What do I have to do to call the properties or the methods of the extending class Rock and not from the mixin, from my subclass myBand?