Skip to content
Justice Tech School

min, max and clear

Go 1.21 added the builtins min, max and clear.

Example
package main

import "fmt"

func main() {
	fmt.Println(min(3, 1, 2), max(3, 1, 2))
	m := map[string]int{"a": 1}
	clear(m)
	fmt.Println(len(m))
}

Result

1 3
0

Exercise

Smallest.

(3, 1, 2)

Quiz Test

What does clear do on a map?

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