Skip to content

Commit

Permalink
fix: change examples for MapKeys and MapValues (#341)
Browse files Browse the repository at this point in the history
  • Loading branch information
luxcgo authored Aug 17, 2024
1 parent da6eb9d commit e74ad7c
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions map_example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,8 @@ func ExampleAssign() {
func ExampleMapKeys() {
kv := map[int]int{1: 1, 2: 2, 3: 3, 4: 4}

result := MapKeys(kv, func(_ int, v int) string {
return strconv.FormatInt(int64(v), 10)
result := MapKeys(kv, func(_ int, k int) string {
return strconv.FormatInt(int64(k), 10)
})

fmt.Printf("%v %v %v %v %v", len(result), result["1"], result["2"], result["3"], result["4"])
Expand All @@ -184,12 +184,12 @@ func ExampleMapKeys() {
func ExampleMapValues() {
kv := map[int]int{1: 1, 2: 2, 3: 3, 4: 4}

result := MapValues(kv, func(_ int, v int) string {
result := MapValues(kv, func(v int, _ int) string {
return strconv.FormatInt(int64(v), 10)
})

fmt.Printf("%v %v %v %v %v", len(result), result[1], result[2], result[3], result[4])
// Output: 4 1 2 3 4
fmt.Printf("%v %q %q %q %q", len(result), result[1], result[2], result[3], result[4])
// Output: 4 "1" "2" "3" "4"
}

func ExampleMapEntries() {
Expand Down

0 comments on commit e74ad7c

Please sign in to comment.