August 2019
Beginner to intermediate
798 pages
17h 2m
English
The constant generator iota is used for declaring a sequence of related values that use incrementing numbers without the need to explicitly type each one of them.
Most of the concepts related to the const keyword, including the constant generator iota, will be illustrated in the constants.go file, which will be presented in four parts.
The first code segment of constants.go is next:
package main
import (
"fmt"
)
type Digit int
type Power2 int
const PI = 3.1415926
const (
C1 = "C1C1C1"
C2 = "C2C2C2"
C3 = "C3C3C3"
)
In this part, we declare two new types named Digit and Power2, and four new constants named PI, C1, C2, and C3.
Read now
Unlock full access