Skip to content

Instantly share code, notes, and snippets.

@tomtsang
Last active February 7, 2018 06:35
Show Gist options
  • Save tomtsang/c50b983a6194208fa904417ac5b1081a to your computer and use it in GitHub Desktop.
Save tomtsang/c50b983a6194208fa904417ac5b1081a to your computer and use it in GitHub Desktop.
golang-switch-pattern3
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