Created
June 27, 2022 20:31
-
-
Save ntatko/1039511d46a7a4cbe122064ad6aa3fef to your computer and use it in GitHub Desktop.
Switch Statements in Dart
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 STATEMENTS | |
| void main() { | |
| String food = "Hamburger"; | |
| switch (food) { | |
| case "Cheeseburger": | |
| case "Hamburger": | |
| case "Burger": | |
| print("This is a burger"); | |
| break; | |
| case "Fries": | |
| print("These are the fries you ordered"); | |
| break; | |
| default: | |
| print("We don't serve that here"); | |
| break; | |
| } | |
| print("all done ordering"); | |
| int number = 10; | |
| switch (number) { | |
| case 1: | |
| case 2: | |
| case 3: | |
| case 4: | |
| case 5: | |
| case 6: | |
| case 7: | |
| case 8: | |
| case 9: | |
| print("only one digit"); | |
| break; | |
| default: | |
| print("more than one digit"); | |
| return; | |
| } | |
| print("done with numbers"); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment