Back to questions
JuniorTheoryCommon
What does the program print?
package main
import "fmt"
func main() {
const (
A = iota
_
C
)
fmt.Println(A, C)
}0 2
- Expecting
0 1: the_line is still a line of the block, soiotais1there and the value is thrown away;Cgets2. - Expecting
0 0: a line with no=repeats the expressioniota, not the value0, andiotagrows by one on every line of the block.
- How would you make the first constant of the block start at
1? - What does
iotaequal in the first line of a second, separateconstblock?