Skip to content

Commit

Permalink
doc: update CoalesceXXX demo and result (#594)
Browse files Browse the repository at this point in the history
  • Loading branch information
jialeicui authored Feb 22, 2025
1 parent fe0618f commit b828ea1
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3265,6 +3265,10 @@ result, ok := lo.CoalesceSlice([]int{1, 2, 3}, []int{4, 5, 6})
result, ok := lo.CoalesceSlice(nil, []int{})
// []
// true

result, ok := lo.CoalesceSlice([]int(nil))
// []
// false
```

### CoalesceSliceOrEmpty
Expand All @@ -3285,12 +3289,16 @@ Returns the first non-zero map.

```go
result, ok := lo.CoalesceMap(map[string]int{"1": 1, "2": 2, "3": 3}, map[string]int{"4": 4, "5": 5, "6": 6})
// [1, 2, 3]
// {"1": 1, "2": 2, "3": 3}
// true

result, ok := lo.CoalesceMap(nil, map[string]int{})
// []
// {}
// true

result, ok := lo.CoalesceMap(map[string]int(nil))
// {}
// false
```

### CoalesceMapOrEmpty
Expand Down

0 comments on commit b828ea1

Please sign in to comment.