[Suggestion] Explain mixin plus the on keyword

Hi don’t know why I can think of so many questions in this chapter of enhanced enum.
About the code of mixin in enhanced enum

enum Fruit with Describer {
  cherry,
  peach,
  banana,
}

enum Vegetable with Describer {
  carrot,
  broccoli,
  spinach,
}

mixin Describer on Enum {
  void describe() {
    print('This $runtimeType is a $name.');
}

I see the on keyword is used on mixin. But when I go back to the chapter on mixin, it doesn’t explain this keyword.

After consulting chatGPT, finally I know that on is used to specify the class or subclass that mixin can be applied.

I think a little bit explanation is needed, otherwise, I will write the following on this context:

mixin Describer implements Enum {
  void describe() {
    print('This $runtimeType is a $name.');
}

Changing from on to implements, the code also compiled with no error and I will never know on can be used on a mixin!

1 Like

Yes, you’re right. Not teaching the on keyword in the mixins chapter was a known issue with this edition of the book. Because I was working on a deadline, I decided to cut it knowing that I wanted to add it in the next edition. It’s actually the second GitHub issue I opened for this edition of the book. What I didn’t realize is that I had inadvertently used that keyword without explaining it in the enhanced enums chapter. Good job on catching both problems.

1 Like