Add examples of maps/slices packages

This commit is contained in:
Eli Bendersky
2023-08-22 05:52:14 -07:00
parent 2166e61181
commit 146bd9cce2
8 changed files with 75 additions and 15 deletions

View File

@@ -3,7 +3,10 @@
package main
import "fmt"
import (
"fmt"
"maps"
)
func main() {
@@ -58,4 +61,11 @@ func main() {
// the same line with this syntax.
n := map[string]int{"foo": 1, "bar": 2}
fmt.Println("map:", n)
// The `maps` package contains a number of useful
// utility functions for maps.
n2 := map[string]int{"foo": 1, "bar": 2}
if maps.Equal(n, n2) {
fmt.Println("n == n2")
}
}

View File

@@ -1,2 +1,2 @@
b976324013ef31370d1605d1834c5dd6f0db0ea1
6gcPOX9Mm1R
c8435b8cc754213b70c58c9a51dfa824c6f70dd7
5jpkxJ2T0Lv

View File

@@ -9,3 +9,4 @@ map: map[k1:7]
map: map[]
prs: false
map: map[bar:2 foo:1]
n == n2