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
相關文章
相關標籤/搜索