golang快速入门-03-golang的常量和iota


  0 const length int = 10


1 //const 来定义枚举类型 2 const ( 3 //可以在const() 添加一个关键字 iota, 每行的iota都会累加1, 第一行的iota的默认值是0 4 BEIJING = iota //iota = 0 5 SHANGHAI //iota = 1 6 SHENZHEN //iota = 2 7 ) 8 9 10 //const 来定义枚举类型 11 const ( 12 //可以在const() 添加一个关键字 iota, 每行的iota都会累加1, 第一行的iota的默认值是0 13 BEIJING = 10*iota //iota = 0 14 SHANGHAI //iota = 10 15 SHENZHEN //iota = 20 16 ) 17 18 // 公式继承,直到被覆盖 19 const ( 20 a, b = iota+1, iota+2 // iota = 0, a = iota + 1, b = iota + 2, a = 1, b = 2 21 c, d // iota = 1, c = iota + 1, d = iota + 2, c = 2, d = 3 22 e, f // iota = 2, e = iota + 1, f = iota + 2, e = 3, f = 4 23 24 g, h = iota * 2, iota *3 // iota = 3, g = iota * 2, h = iota * 3, g = 6, h = 9 25 i, k // iota = 4, i = iota * 2, k = iota * 3 , i = 8, k = 12 26 )
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值