代码
type People interface {
Show()
}
type Student struct {
}
func (stu *Student) Show() {
}
func live() People {
var stu *Student
return stu
}
func main() {
if live() == nil {
fmt.Println("A")
} else {
fmt.Println("B")
}
}
我查了好久也没找到 为什么 live()返回值强制转换为 interface 类型后 live 返回值依然为 nil,但是 live() == nil 为 false ! 请大神指点一下。