case
This commit is contained in:
parent
b2e5879257
commit
7945544a0a
@ -1,16 +0,0 @@
|
|||||||
package main
|
|
||||||
|
|
||||||
import "fmt"
|
|
||||||
|
|
||||||
func main() {
|
|
||||||
i := 3
|
|
||||||
switch i {
|
|
||||||
case 0: fmt.Println("Zero")
|
|
||||||
case 1: fmt.Println("One")
|
|
||||||
case 2: fmt.Println("Two")
|
|
||||||
case 3: fmt.Println("Three")
|
|
||||||
case 4: fmt.Println("Four")
|
|
||||||
case 5: fmt.Println("Five")
|
|
||||||
default: fmt.Println("Unknown Number")
|
|
||||||
}
|
|
||||||
}
|
|
26
010-case/case.go
Normal file
26
010-case/case.go
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
// ## Case
|
||||||
|
|
||||||
|
package main
|
||||||
|
|
||||||
|
import "fmt"
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
fmt.Print("Write 3 as ")
|
||||||
|
i := 3
|
||||||
|
switch i {
|
||||||
|
case 0:
|
||||||
|
fmt.Println("zero")
|
||||||
|
case 1:
|
||||||
|
fmt.Println("one")
|
||||||
|
case 2:
|
||||||
|
fmt.Println("two")
|
||||||
|
case 3:
|
||||||
|
fmt.Println("three")
|
||||||
|
case 4:
|
||||||
|
fmt.Println("four")
|
||||||
|
case 5:
|
||||||
|
fmt.Println("five")
|
||||||
|
default:
|
||||||
|
fmt.Println("???")
|
||||||
|
}
|
||||||
|
}
|
2
010-case/case.sh
Normal file
2
010-case/case.sh
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
$ go run case.go
|
||||||
|
Write 3 as three
|
Loading…
x
Reference in New Issue
Block a user