Created with <3 with dartpad.dev.
Created
September 25, 2023 06:29
-
-
Save maks/28614c26d39003179875f42369b035d9 to your computer and use it in GitHub Desktop.
reverberating-oak-9145
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
// Example of using Dart 3 switch expression | |
void main() { | |
print("code: ${process('ok')}"); | |
} | |
Code process(String res) { | |
return switch(res) { | |
"ok" => Code.ok, | |
"error" => Code.ok, | |
_ => Code.undefined | |
}; | |
} | |
enum Code { ok, error, undefined } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment