Skip to content

Instantly share code, notes, and snippets.

@maks
Created September 25, 2023 06:29
Show Gist options
  • Save maks/28614c26d39003179875f42369b035d9 to your computer and use it in GitHub Desktop.
Save maks/28614c26d39003179875f42369b035d9 to your computer and use it in GitHub Desktop.
reverberating-oak-9145

reverberating-oak-9145

Created with <3 with dartpad.dev.

// 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