Back to Lo

Core Clone

docs/data/core-clone.md

1.53.0236 B
Original Source

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}