Back to Lo

Core Cutsuffix

docs/data/core-cutsuffix.md

1.53.0387 B
Original Source

Returns the collection without the provided trailing suffix and a boolean indicating whether it was present.

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

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