Constants and iota
const holds fixed values. iota counts up inside a const block, great for enums.
Example
package main
import "fmt"
func main() {
const Pi = 3.14
const (
A = iota
B
C
)
fmt.Println(Pi, A, B, C)
}Result
3.14 0 1 2
Exercise
Constant keyword.
Max = 10Quiz Test
These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.