mirror of
https://github.com/samber/lo.git
synced 2026-04-22 23:47:11 +08:00
683 B
683 B
name, slug, sourceRef, category, subCategory, signatures, variantHelpers, similarHelpers, position
| name | slug | sourceRef | category | subCategory | signatures | variantHelpers | similarHelpers | position | |||
|---|---|---|---|---|---|---|---|---|---|---|---|
| Replace | replace | it/seq.go#L699 | it | slice |
|
|
|
190 |
Replace returns a sequence with the first n non-overlapping instances of old replaced by new.
collection := func(yield func(int) bool) {
yield(1)
yield(2)
yield(2)
yield(3)
yield(2)
yield(4)
}
replaced := it.Replace(collection, 2, 99, 2)
var result []int
for item := range replaced {
result = append(result, item)
}
// result contains [1, 99, 99, 3, 2, 4]