Let me filter out the egg laying code since it doesn’t apply to the interesting behavior:
void main() {
final robin = Robin();
robin.fly();
// Swoosh swoosh
// child child
}
mixin Flyer {
void fly() {
print('Swoosh swoosh');
}
}
abstract class Bird {
void fly() {
print("parent parent");
}
}
class Robin extends Bird with Flyer {
@override
void fly() {
super.fly();
print("child child");
}
}
You’ve got three separate implementations of fly. Normally super.fly() would print “parent parent”, but the mixin overrides the parent method. However, the mixin doesn’t override the child method. That is interesting.
I like how you’re exploring the edges of the language. Good job.
@suragch thank you for your appreciation. I don’t intent to test it like that at the first reading. But when I try to write the notes for mixin section, the idea of using super.fly() suddenly pop up in my head. So, that’s the origin of coming up this idea.