lecture 65
This commit is contained in:
@@ -2,13 +2,18 @@ package main
|
|||||||
|
|
||||||
import "fmt"
|
import "fmt"
|
||||||
|
|
||||||
func main () {
|
func main() {
|
||||||
i := 0
|
i := 0
|
||||||
|
|
||||||
loop:
|
loop:
|
||||||
if i < 5{
|
if i < 5 {
|
||||||
fmt.Println(i)
|
fmt.Println(i)
|
||||||
i++
|
i++
|
||||||
goto loop
|
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