Back to Lo

Core Coalescesliceorempty

docs/data/core-coalescesliceorempty.md

1.53.0375 B
Original Source

Returns the first non-empty slice from the provided arguments, or an empty slice if all arguments are empty.

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

result = lo.CoalesceSliceOrEmpty([]int{}, []int{})
// []int{}

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