What is a rune
in Go?
I\'ve been googling but Golang only says in one line: rune
is an alias for int32
.
But h
Everyone else has covered the part related to runes, so I am not going to talk about that.
However, there is also a question related to switch
not having any arguments. This is simply because in Golang, switch
without an expression is an alternate way to express if/else logic. For example, writing this:
t := time.Now()
switch {
case t.Hour() < 12:
fmt.Println("It's before noon")
default:
fmt.Println("It's after noon")
}
is same as writing this:
t := time.Now()
if t.Hour() < 12 {
fmt.Println("It's before noon")
} else {
fmt.Println("It's after noon")
}
You can read more here.