Created
July 25, 2022 10:11
-
-
Save ashphy/6191133153e76d38d8b0bb0893a445c5 to your computer and use it in GitHub Desktop.
Dart2.17 enhanced-enums implements interface sample
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
abstract class Abstract { | |
void foo(); | |
} | |
enum Categoly implements Abstract { | |
sample1, | |
sample2; | |
@override | |
foo() { print(this); } | |
} | |
enum Division implements Abstract { | |
sample1, | |
sample2; | |
@override | |
foo() { print(this); } | |
} | |
void test<T extends Abstract>(T type) { | |
type.foo(); | |
} | |
void main() { | |
test(Categoly.sample1); | |
test(Division.sample2); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment