On Wednesday, 3 May 2017 07:34:16 UTC+3, Tong Sun wrote:
>
> Hi, 
>
> How to use `iota` to define consts that have gap(s) in them? 
>
> E.g., If my consts are, 
>
> 1, 2, 3, 7, 8, 9
>
> How to use iota to define them? Thx. 
>

You don't have to use iota. If these are predefined constants, such as a 
protocol -- it's usually better to assign them explicitly rather than to 
use iota.

There are also:

// use skip
const (
A = iota
B
C
D = iota + 3 // for skip 3
E
) // 0, 1, 2, 6, 7

// use multiple iotas
const (
A = iota
B
C
)
const (
D = iota + 100 // new iota starting from 100
E
) // 0, 1, 2, 100, 101

+ Egon

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to