mirror of
https://github.com/samber/lo.git
synced 2026-04-22 23:47:11 +08:00
Add Clone function to return shallow copy of slice collections (#732)
* Initial plan * Add Clone function to return shallow copy of slice collection Co-authored-by: quexer <92157+quexer@users.noreply.github.com> * Update slice.go Co-authored-by: Samuel Berthe <dev@samuel-berthe.fr> * Update slice_test.go Co-authored-by: Samuel Berthe <dev@samuel-berthe.fr> * doc and test * Apply suggestions from code review --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: quexer <92157+quexer@users.noreply.github.com> Co-authored-by: Samuel Berthe <dev@samuel-berthe.fr>
This commit is contained in:
@@ -2503,6 +2503,16 @@ func ExampleReplace() {
|
||||
// [42 1 42 1 2 3 42]
|
||||
}
|
||||
|
||||
func ExampleClone() {
|
||||
input := []int{1, 2, 3, 4, 5}
|
||||
|
||||
output := Clone(input)
|
||||
input[0] = 42
|
||||
|
||||
fmt.Printf("%v", output)
|
||||
// Output: [1 2 3 4 5]
|
||||
}
|
||||
|
||||
func ExampleCompact() {
|
||||
list := []string{"", "foo", "", "bar", ""}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user