Files
lo/docs/data/it-trimsuffix.md
T
Samuel Berthe fa095e4b4f fix(doc): fix go playground demo URL (#832)
* fix(doc): fix go playground demo URL

* fix(doc): add more go playground demo URL
2026-03-06 00:09:59 +01:00

675 B

name, slug, sourceRef, category, subCategory, signatures, playUrl, variantHelpers, similarHelpers, position
name slug sourceRef category subCategory signatures playUrl variantHelpers similarHelpers position
TrimSuffix trimsuffix it/seq.go#L778 it string
func TrimSuffix[T comparable, I ~func(func(T) bool)](collection I, suffix []T) I
https://go.dev/play/p/s9nwy9helEi
core#string#trimsuffix
266

TrimSuffix removes all the trailing suffix from the collection.

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

trimmed := it.TrimSuffix(collection, []int{3, 4})
var result []int
for item := range trimmed {
    result = append(result, item)
}
// result contains [1, 2]