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

553 B

name, slug, sourceRef, category, subCategory, playUrl, variantHelpers, similarHelpers, position, signatures
name slug sourceRef category subCategory playUrl variantHelpers similarHelpers position signatures
Clone clone slice.go#L741 core slice https://go.dev/play/p/66LJ2wAF0rN
core#slice#clone
core#slice#repeat
core#slice#fill
160
func Clone[T any, Slice ~[]T](collection Slice) Slice

Returns a shallow copy of the collection.

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}