Declare Multiple Variables
Declare several variables in one line with commas or a var block. The blank identifier _ ignores a value you do not need.
Example
a, b, c := 1, "two", 3.0
var x, y int = 10, 20
var (
name = "Ada"
ok = true
)
_, second := 1, 2
fmt.Println(a, b, c, x, y, name, ok, second)Result
1 two 3 10 20 Ada true 2
Exercise
Ignore a value.
, n := 1, 2Quiz Test
These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.