Created with <3 with dartpad.dev.
Last active
August 26, 2023 22:47
-
-
Save catalunha/86581ad001227319a86e14930943d210 to your computer and use it in GitHub Desktop.
ResumoDart - Switch
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
// 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