Skip to content

Commit

Permalink
update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
wenlingang committed Jun 29, 2024
1 parent 5e79a80 commit 00663d1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
9 changes: 4 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,7 @@ Supported helpers for slices:
- [Compact](#compact)
- [IsSorted](#issorted)
- [IsSortedByKey](#issortedbykey)
- [Insert](#insert)
- [InsertSlice](#insertslice)
- [Splice](#Splice)

Supported helpers for maps:

Expand Down Expand Up @@ -936,12 +935,12 @@ result := lo.Insert(["a", "c", "d"], 1, "b")

[[play](https://go.dev/play/p/Eu3pk6_ODVQ)]

### InsertSlice
### Splice

Inserts multiple elements at index i.
Splice multiple elements at index i.

```go
result := lo.InsertSlice([]string{"a", "d"}, 1, []string{"b", "c"})
result := lo.Splice([]string{"a", "d"}, 1, "b", "c")
// []string{"a", "b", "c", "d"}
```

Expand Down
2 changes: 2 additions & 0 deletions slice_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -765,8 +765,10 @@ func TestInsertSlice(t *testing.T) {
is := assert.New(t)

inserts := Splice([]string{"a", "d"}, 1, "b", "c")
is.Equal(inserts, []string{"a", "b", "c", "d"})
is.True(len(inserts) == 4 && inserts[1] == "b" && inserts[2] == "c")

inserti := Splice([]int{1, 4}, 1, 2, 3)
is.Equal(inserti, []int{1, 2, 3, 4})
is.True(len(inserti) == 4 && inserti[1] == 2 && inserti[2] == 3)
}

0 comments on commit 00663d1

Please sign in to comment.