feat: add GetOrSet

This commit is contained in:
dudaodong committed 2024-06-24 17:28:51 +08:00
1 parent aeef0418a4
commit a220220f09
5 files changed
+122

No files matched your search

+16
View File
@@ -524,3 +524,19 @@ func ExampleToSortedSlicesWithComparator() {
// [3 2 1]
// [c b a]
}
func ExampleGetOrSet() {
m := map[int]string{
1: "a",
}
result1 := GetOrSet(m, 1, "1")
result2 := GetOrSet(m, 2, "b")
fmt.Println(result1)
fmt.Println(result2)
// Output:
// a
// b
}