iota的一个特别用法

const(
    a = iota // 0
    b        // 1
    c        // 2
)



const(
   a = iota  // 0
   b = 100   // 100
   c = iota  // 2
   d         // 3
)



const(
   a, b = iota + 1, iota + 2  // 1,2
   c, d                       // 2,3
   e, f                       // 3,4
)
发布了64 篇原创文章 · 获赞 26 · 访问量 36万+

猜你喜欢

转载自blog.csdn.net/moliyiran/article/details/104247222