lecture 65
This commit is contained in:
@@ -2,13 +2,18 @@ package main
|
||||
|
||||
import "fmt"
|
||||
|
||||
func main () {
|
||||
func main() {
|
||||
i := 0
|
||||
|
||||
loop:
|
||||
if i < 5{
|
||||
if i < 5 {
|
||||
fmt.Println(i)
|
||||
i++
|
||||
goto loop
|
||||
}
|
||||
// THIS IS AN ERROR
|
||||
// goto todo
|
||||
// x := 5
|
||||
// todo:
|
||||
// fmt.Println("something here")
|
||||
}
|
||||
43
Section6/65.go
Normal file
43
Section6/65.go
Normal file
@@ -0,0 +1,43 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
)
|
||||
|
||||
func main() {
|
||||
language := "golang"
|
||||
|
||||
switch language {
|
||||
case "Python":
|
||||
fmt.Println("You are learnig Python! You don't use curly braces but indentation!!")
|
||||
|
||||
case "go", "golang":
|
||||
fmt.Println("Good, go for Go! You are using curly braces {}!")
|
||||
|
||||
default:
|
||||
fmt.Println("Any other programming language is a good start!")
|
||||
}
|
||||
|
||||
n := 5
|
||||
switch true {
|
||||
case n%2 == 0:
|
||||
fmt.Println("Even number")
|
||||
case n%2 != 0:
|
||||
fmt.Println("Odd number")
|
||||
default:
|
||||
fmt.Println("Never here!!")
|
||||
}
|
||||
|
||||
hour := time.Now().Hour()
|
||||
fmt.Println(hour)
|
||||
|
||||
switch {
|
||||
case hour < 12:
|
||||
fmt.Println("Good morning")
|
||||
case hour < 17:
|
||||
fmt.Println("Good afernoon")
|
||||
default:
|
||||
fmt.Println("Good evening")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user