

0 / 2 embers
0 / 3000 xp
click for more info
Complete a lesson to start your streak
click for more info
Difficulty: 3
click for more info
Not enough gems
Cost: 6 gems
1: Lack of Enums
incomplete
2: Type Definitions
incomplete
3: Iota
incomplete
This lesson's interactive features are locked, please to keep using them
Go has a language feature, that when used with a type definition (and if you squint really hard), kinda looks like an enum (but it's not). It's called iota.
type sendingChannel int
const (
Email sendingChannel = iota
SMS
Phone
)
The iota keyword is a special keyword in Go that creates a sequence of numbers. It starts at 0 and increments by 1 for each constant in the const block. So in the example above, Email is 0, SMS is 1, and Phone is 2.
Go developers sometimes use iota to create a sequence of constants to represent a set of related values, much like you would with an enum in other languages. But remember, it's not an enum. It's just a sequence of numbers.
Define an emailStatus type that uses iota syntax to represent the following states:
EmailBounced: 0EmailInvalid: 1EmailDelivered: 2EmailOpened: 3