有人能解释一下这行代码是怎么回事吗?
type Fate int
const (
Decided Fate = iota + 1
Pending // not yet decided.
Forgotten // decided but forgotten.
)
我不明白决定、等待和遗忘应该是什么.
有人能解释一下这行代码是怎么回事吗?
type Fate int
const (
Decided Fate = iota + 1
Pending // not yet decided.
Forgotten // decided but forgotten.
)
我不明白决定、等待和遗忘应该是什么.
在const
块内,每个连续的IOTA表示递增的整数常量.如果不提供用于初始化常量的表达式,则最后一个表达式将隐式重复,因此您的代码等同于:
const {
Decided Fate = iota + 1 // 1
Pending Fate = iota + 1 // 2
Forgotten Fate = iota + 1 // 3
)