支持 ExtractKeys 和 ExtractValues 方法 (#92)

This commit is contained in:
libin
2025-07-08 11:15:28 +08:00
committed by GitHub
parent f71f6c495b
commit c36cad7d1b
7 changed files with 304 additions and 0 deletions

View File

@@ -0,0 +1,17 @@
package mapUtil
import (
"fmt"
"sort"
)
func ExampleExtractValues() {
m := map[string]int{"apple": 5, "banana": 3, "orange": 7}
values := ExtractValues(m)
// 对结果排序以确保输出一致map 迭代顺序随机)
sort.Ints(values)
fmt.Println("Values:", values)
// Output: Values: [3 5 7]
}