Last active
February 7, 2018 06:35
-
-
Save tomtsang/c50b983a6194208fa904417ac5b1081a to your computer and use it in GitHub Desktop.
golang-switch-pattern3
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
switch initialization { | |
case val1: | |
... | |
case val2: | |
... | |
default: | |
... | |
} | |
switch result := calculate(); { | |
case result < 0: | |
... | |
case result > 0: | |
... | |
default: | |
// 0 | |
} | |
switch a, b := x[i], y[j]; { | |
case a < b: t = -1 | |
case a == b: t = 0 | |
case a > b: t = 1 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment