Go语言之nil详解

Go语言中的nil远比java中的null要难以理解和掌握。java 1.普通的 struct(非指针类型)的对象不能赋值为 nil,也不能和 nil 进行判等(==),即以下代码,不能判断 *s == nil(编译错误),也不能写:var s Student = nil。指针 s := new(Student) //使用new建立一个 *Student 类型对象 fmt.Println("s
相关文章
相关标签/搜索