Back to Lo

Core Cut

docs/data/core-cut.md

1.53.0437 B
Original Source

Slices the collection around the first instance of the separator, returning before, after, and whether it was found.

go
left, right, found := lo.Cut([]string{"a", "b", "c", "d", "e", "f", "g"}, []string{"b", "c", "d"})
// left: []string{"a"}
// right: []string{"e", "f", "g"}
// found: true

left, right, found = lo.Cut([]string{"a", "b", "c"}, []string{"z"})
// left: []string{"a", "b", "c"}
// right: []string{}
// found: false