Files
lo/docs/data/core-clone.md
T
Samuel Berthe fa095e4b4f fix(doc): fix go playground demo URL (#832)
* fix(doc): fix go playground demo URL

* fix(doc): add more go playground demo URL
2026-03-06 00:09:59 +01:00

27 lines
553 B
Markdown

---
name: Clone
slug: clone
sourceRef: slice.go#L741
category: core
subCategory: slice
playUrl: https://go.dev/play/p/66LJ2wAF0rN
variantHelpers:
- core#slice#clone
similarHelpers:
- core#slice#repeat
- core#slice#fill
position: 160
signatures:
- "func Clone[T any, Slice ~[]T](collection Slice) Slice"
---
Returns a shallow copy of the collection.
```go
in := []int{1, 2, 3, 4, 5}
cloned := lo.Clone(in)
// Verify it's a different slice by checking that modifying one doesn't affect the other
in[0] = 99
// cloned is []int{1, 2, 3, 4, 5}
```