feat: add Values func

This commit is contained in:
dudaodong committed 2022-03-30 17:34:01 +08:00
1 parent be942ec33e
commit ae54c8db6f
1 file changed
+11
+11
View File
@@ -14,3 +14,14 @@ func Keys[K comparable, V any](m map[K]V) []K {
return keys
}
// Values returns a slice of the map's values
func Values[K comparable, V any](m map[K]V) []V {
values := make([]V, len(m))
for _, v := range m {
values = append(values, v)
}
return values
}