Created
June 13, 2022 19:56
-
-
Save eernstg/27945e73fc4fda552d1c341b9895d561 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
enum Key { | |
key1, | |
key2; | |
T mapFor<T>({ | |
required T Function() key1, | |
required T Function() key2, | |
}) { | |
switch (this) { | |
case Key.key1: return key1(); | |
case Key.key2: return key2(); | |
} | |
} | |
} | |
void main() { | |
Key key = Key.key1; | |
key.mapFor( | |
key1: () => print('This was key1'), | |
key2: () => print('This was key2'), | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment