diff --git a/map_example_test.go b/map_example_test.go index 3a9b66ab..8edc7fe0 100644 --- a/map_example_test.go +++ b/map_example_test.go @@ -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"]) @@ -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() {