Skip to content

Instantly share code, notes, and snippets.

@catalunha
Last active August 26, 2023 22:47
Show Gist options
  • Save catalunha/86581ad001227319a86e14930943d210 to your computer and use it in GitHub Desktop.
Save catalunha/86581ad001227319a86e14930943d210 to your computer and use it in GitHub Desktop.
ResumoDart - Switch
// switch com => retorna valor. Ambos analisam exaustão.
enum Valores { A, B, C }
void main() {
Valores vlr1 = Valores.B;
print(vlr1);
switch (vlr1) {
case Valores.A:
print('aa');
print('aa2');
case Valores.B:
print('bb');
// case Valores.C:
// print('cc');
// default:
// print('dd');
}
;
final b = switch (vlr1) {
Valores.A => 'a',
Valores.B => 'b',
// Valores.C => 'c',
};
print(b);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment