Add examples of maps/slices packages
This commit is contained in:
@@ -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")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
b976324013ef31370d1605d1834c5dd6f0db0ea1
|
||||
6gcPOX9Mm1R
|
||||
c8435b8cc754213b70c58c9a51dfa824c6f70dd7
|
||||
5jpkxJ2T0Lv
|
||||
|
||||
@@ -9,3 +9,4 @@ map: map[k1:7]
|
||||
map: map[]
|
||||
prs: false
|
||||
map: map[bar:2 foo:1]
|
||||
n == n2
|
||||
|
||||
Reference in New Issue
Block a user