Back to Lo

Core Trimsuffix

docs/data/core-trimsuffix.md

1.53.0305 B
Original Source

Removes all trailing occurrences of the given suffix from the collection.

go
result := lo.TrimSuffix([]int{1, 2, 3, 1, 2, 4, 2, 4, 2, 4}, []int{2, 4})
// []int{1, 2, 3, 1}

result = lo.TrimSuffix([]string{"hello", "world", "hello", "test"}, []string{"test"})
// []string{"hello", "world", "hello"}