mirror of
https://github.com/duke-git/lancet.git
synced 2026-11-16 05:12:11 +08:00
feat: add Merge func
This commit is contained in:
1 parent
1af8fe8daf
commit
1a436aeb41
2 files changed
+35
No files matched your search
@@ -25,3 +25,16 @@ func Values[K comparable, V any](m map[K]V) []V {
|
||||
|
||||
return values
|
||||
}
|
||||
|
||||
// Merge maps, next key will overwrite previous key
|
||||
func Merge[K comparable, V any](maps ...map[K]V) map[K]V {
|
||||
res := make(map[K]V, 0)
|
||||
|
||||
for _, m := range maps {
|
||||
for k, v := range m {
|
||||
res[k] = v
|
||||
}
|
||||
}
|
||||
|
||||
return res
|
||||
}
|
||||
Reference in new issue
Block a user