Go

What will be the output of the following block of code?:

package main

import "fmt"

const (
	x = iota
	y = iota
)
const z = iota

func main() {
	fmt.Printf("%v\n", x)
	fmt.Printf("%v\n", y)
	fmt.Printf("%v\n", z)
}

Difficulty: unrated

Source: bregman-arie/devops-exercises by Arie Bregman

Answer

Go's iota identifier is used in const declarations to simplify definitions of incrementing numbers. Because it can be used in expressions, it provides a generality beyond that of simple enumerations.

x and y in the first iota group, z in the second.

Iota page in Go Wiki