Back to Lo

Core Cutprefix

docs/data/core-cutprefix.md

1.53.0360 B
Original Source

Returns the collection without the provided leading prefix and a boolean indicating whether it was present.

go
right, found := lo.CutPrefix([]string{"a", "b", "c", "d"}, []string{"a", "b", "c"})
// right: []string{"d"}
// found: true

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