Go: Count elements in a map
The call len(m)
returns the number of key-value pairs in m
.
m := map[string]int{
"key1": 1,
"key2": 10,
"key3": 100,
}
fmt.Println(len(m)) // 3
Comments
Be the first to comment!