-
Notifications
You must be signed in to change notification settings - Fork 3.6k
/
main.go
32 lines (27 loc) · 785 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package main
import "fmt"
func main() {
myFriendsName := "Mar"
switch {
case len(myFriendsName) == 2:
fmt.Println("Wassup my friend with name of length 2")
case myFriendsName == "Tim":
fmt.Println("Wassup Tim")
case myFriendsName == "Jenny":
fmt.Println("Wassup Jenny")
case myFriendsName == "Marcus", myFriendsName == "Medhi":
fmt.Println("Your name is either Marcus or Medhi")
case myFriendsName == "Julian":
fmt.Println("Wassup Julian")
case myFriendsName == "Sushant":
fmt.Println("Wassup Sushant")
default:
fmt.Println("nothing matched; this is the default")
}
}
/*
expression not needed
-- if no expression provided, go checks for the first case that evals to true
-- makes the switch operate like if/if else/else
cases can be expressions
*/