Files
lo/docs/data/it-cutsuffix.md
T
2025-10-06 17:16:33 +02:00

818 B

name, slug, sourceRef, category, subCategory, signatures, variantHelpers, similarHelpers, position
name slug sourceRef category subCategory signatures variantHelpers similarHelpers position
CutSuffix cutsuffix it/seq.go#L778 it string
func CutSuffix[T comparable, I ~func(func(T) bool)](collection I, separator []T) (before I, found bool)
core#string#cutsuffix
261

CutSuffix returns collection without the provided ending suffix and reports whether it found the suffix. If collection doesn't end with suffix, CutSuffix returns collection, false. If suffix is empty, CutSuffix returns collection, true.

collection := func(yield func(int) bool) {
    yield(1)
    yield(2)
    yield(3)
    yield(4)
}

before, found := it.CutSuffix(collection, []int{3, 4})
var result []int
for item := range before {
    result = append(result, item)
}
// result contains [1, 2], found is true