Back to Lo

Core Coalesceslice

docs/data/core-coalesceslice.md

1.53.0397 B
Original Source

Returns the first non-empty slice from the provided arguments, with a boolean indicating if a non-empty slice was found.

go
result, ok := lo.CoalesceSlice([]int{}, []int{1, 2, 3}, []int{4, 5})
// []int{1, 2, 3}, true

result, ok = lo.CoalesceSlice([]int{}, []int{})
// []int{}, false

result, ok = lo.CoalesceSlice([]string{}, []string{"a", "b"}, []string{"c"})
// []string{"a", "b"}, true