0

I have a single group of constant:

const (
    a = 100
    b = 200
    c = 300
)

I was wondering if there is any way to use iota keyword instead of assigning each value manually?

As described in the official reference, it is possible to use bitwise shift with iota to increase numbers, but I want to increase by a fixed number like 100 for example.

Amid
  • 442
  • 2
  • 8
  • 15

1 Answers1

3
const (
    _ = iota * 100
    a
    b
    c
)

https://play.golang.org/p/V-2Uv9JPj6g

mkopriva
  • 35,176
  • 4
  • 57
  • 71