This is code from Golang Tutorial : Go Full Course at 2:37:32
I cannot understand what he mean when using .(Cat) on kitty
Is he kind of type casting or something on the kitty interface to Cat type?(IDK what I am talking, please help)
Please share a link to the documentation if possible
var kitty2 Cat = kitty.(Cat)
package main
type Cat string
type Animal interface {
happy() string
sad() string
}
func (c Cat) happy() string {
return "haha"
}
func (c Cat) sad() string {
return ":("
}
func main() {
var kitty Animal
kitty = Cat("kitty")
var kitty2 Cat = kitty.(Cat)
}