支持 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 ExampleExtractKeys() {
m := map[string]int{"apple": 5, "banana": 3, "orange": 7}
keys := ExtractKeys(m)
// 对结果排序以确保输出一致map 迭代顺序随机)
sort.Strings(keys)
fmt.Println("Keys:", keys)
// Output: Keys: [apple banana orange]
}