mirror of
https://github.com/duke-git/lancet.git
synced 2026-02-12 08:42:29 +08:00
feat: add GetOrSet
This commit is contained in:
@@ -437,7 +437,7 @@ func ToSortedSlicesWithComparator[K comparable, V any](m map[K]V, comparator fun
|
|||||||
return keys, sortedValues
|
return keys, sortedValues
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetOrSet returns value of the given key or set the given value value if not present
|
// GetOrSet returns value of the given key or set the given value value if not present.
|
||||||
// Play: todo
|
// Play: todo
|
||||||
func GetOrSet[K comparable, V any](m map[K]V, key K, value V) V {
|
func GetOrSet[K comparable, V any](m map[K]V, key K, value V) V {
|
||||||
if v, ok := m[key]; ok {
|
if v, ok := m[key]; ok {
|
||||||
|
|||||||
Reference in New Issue
Block a user