lean into examples

This commit is contained in:
Mark McGranaghan
2012-10-09 21:02:12 -07:00
parent 5d1775bdaa
commit 8daa226a48
130 changed files with 4 additions and 4 deletions

30
examples/switch/switch.go Normal file
View File

@@ -0,0 +1,30 @@
// Switch statements allow...
package main
import "fmt"
func main() {
fmt.Print("Write 3 as ")
i := 3
// Some basic commentary on switches.
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")
// The `default` branch is optional in a `switch`.
default:
fmt.Println("???")
}
}
// todo: more complex / non-constant switch?

View File

@@ -0,0 +1,2 @@
$ go run switch.go
Write 3 as three