golang 使用 iota

iota是golang語言的常量計數器,只能在常量的表達式中使用golang iota在const關鍵字出現時將被重置爲0(const內部的第一行以前),const中每新增一行常量聲明將使iota計數一次(iota可理解爲const語句塊中的行索引)code const ( a = iota b c d ) fmt.Println(a) //0 fmt.Println(b)
相關文章
相關標籤/搜索