Skip to content

Commit

Permalink
Update README.md for Splice() (#94)
Browse files Browse the repository at this point in the history
tiendc authored Oct 7, 2024
1 parent 0becece commit 68af6f2
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -292,6 +292,12 @@ ReplaceAll([]int{1, 2, 1, 3, 1}, 1, 11) // []int{11, 2, 11, 3, 11}

Removes a portion of the given slice and inserts elements of another slice into that position.

Usage: `Splice(s []T, start int, deleteCount int, insertingElements ...T)`.
If `start < -len(s)`, `0` is used.
If `-len(s) <= start < 0`, `start + len(s)` is used.
If `start >= len(s)`, no element will be deleted, but the new elements are still added to the end.
If `deleteCount <= 0`, no elements will be removed.

```go
s := Splice([]int{1, 2, 3}, 1, 1, 100) // s == []int{1, 100, 3}
s := Splice([]int{1, 2, 3}, 1, 0, 100) // s == []int{1, 100, 2, 3}

0 comments on commit 68af6f2

Please sign in to comment.