-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add default case to switch statements (#126)
* add token * add default case to parser * evaluate default cases
- Loading branch information
Showing
6 changed files
with
157 additions
and
32 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,16 @@ | ||
// value = true | ||
|
||
// switch (value) { | ||
// case false { | ||
// print("false.") | ||
// } | ||
|
||
// case true { | ||
// print("true.") | ||
// } | ||
// } | ||
|
||
beverage = "coffee" | ||
beverage = "tea" | ||
|
||
switch (beverage) { | ||
case "water" { | ||
print("Water is $0.75 per bottle.") | ||
} | ||
case "juice" { | ||
print("Juice is $1.25 per bottle.") | ||
} | ||
case "coffee", "latte" { | ||
print("Coffee and lattes are $2.75 per 12oz.") | ||
} | ||
case "water" { | ||
print("Water is $0.75 per bottle.") | ||
} | ||
case "juice" { | ||
print("Juice is $1.25 per bottle.") | ||
} | ||
case "coffee", "latte" { | ||
print("Coffee and lattes are $2.75 per 12oz.") | ||
} | ||
default { | ||
print("Unknown beverage.") | ||
} | ||
} |
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
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
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
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