Codes
package main import "fmt" type color byte const ( black color = iota red blue ) func test(c color) { fmt.Println(c) } func main() { const ( x = iota // 0 y // 1 z // 2 ) fmt.Printf("x=%v, y=%v, z=%v\n", x, y, z) const ( _ = iota KB = 1Result
x=0, y=1, z=2
KB=1024, MB=1048576, GB=1073741824
aa=1, bb=10, cc=2, dd=20
a=0, b=1, c=100, d=100, e=4, f=5
g: int 0, f: float32 1, h: int 2
0
1
2
100总结
以上就是这篇文章的全部内容了,希望本文的内容对大家的学习或者工作具有一定的参考学习价值,谢谢大家对的支持。如果你想了解更多相关内容请查看下面相关链接
查看更多关于Golang常量iota的使用实例的详细内容...
声明:本文来自网络,不代表【好得很程序员自学网】立场,转载请注明出处:http://www.haodehen.cn/did19014