mirror of
https://github.com/jefferyjob/go-easy-utils.git
synced 2025-11-01 19:02:58 +08:00
支持 ExtractKeys 和 ExtractValues 方法 (#92)
This commit is contained in:
10
mapUtil/extract_values.go
Normal file
10
mapUtil/extract_values.go
Normal file
@@ -0,0 +1,10 @@
|
||||
package mapUtil
|
||||
|
||||
// ExtractValues 提取Map的所有值
|
||||
func ExtractValues[K comparable, V any](m map[K]V) []V {
|
||||
values := make([]V, 0, len(m))
|
||||
for _, v := range m {
|
||||
values = append(values, v)
|
||||
}
|
||||
return values
|
||||
}
|
||||
Reference in New Issue
Block a user