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!