Tsallaka zuwa abun ciki
Justice Tech School

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, 2

Quiz Test

What does _ do?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.