From 00663d10689f1e863b733a6cac3091050dbcfa8f Mon Sep 17 00:00:00 2001 From: wenlingang Date: Sat, 29 Jun 2024 10:43:21 +0800 Subject: [PATCH] update readme --- README.md | 9 ++++----- slice_test.go | 2 ++ 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 5019b890..26add363 100644 --- a/README.md +++ b/README.md @@ -116,8 +116,7 @@ Supported helpers for slices: - [Compact](#compact) - [IsSorted](#issorted) - [IsSortedByKey](#issortedbykey) -- [Insert](#insert) -- [InsertSlice](#insertslice) +- [Splice](#Splice) Supported helpers for maps: @@ -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"} ``` diff --git a/slice_test.go b/slice_test.go index 6f6bda19..49b8ea34 100644 --- a/slice_test.go +++ b/slice_test.go @@ -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) }