Advertisement
cwchen

[Go] switch without variable demo

Sep 14th, 2017
405
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Go 0.27 KB | None | 0 0
  1. package main
  2.  
  3. import (
  4.     "fmt"
  5. )
  6.  
  7. func main() {
  8.     score := 88
  9.  
  10.     switch {
  11.     case score >= 90:
  12.         fmt.Println("A")
  13.     case score >= 80:
  14.         fmt.Println("B")
  15.     case score >= 70:
  16.         fmt.Println("C")
  17.     case score >= 60:
  18.         fmt.Println("D")
  19.     default:
  20.         fmt.Println("F")
  21.     }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement