mirror of
https://github.com/samber/lo.git
synced 2026-04-22 23:47:11 +08:00
721 B
721 B
name, slug, sourceRef, category, subCategory, playUrl, variantHelpers, similarHelpers, position, signatures
| name | slug | sourceRef | category | subCategory | playUrl | variantHelpers | similarHelpers | position | signatures | |||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Reverse | reverse | mutable/slice.go#L65 | mutable | slice | https://go.dev/play/p/O-M5pmCRgzV |
|
|
30 |
|
Reverses the slice in place so the first element becomes the last, the second becomes the second-to-last, and so on.
import lom "github.com/samber/lo/mutable"
list := []int{0, 1, 2, 3, 4, 5}
lom.Reverse(list)
// list -> []int{5, 4, 3, 2, 1, 0}
With custom types:
type Point struct{ X, Y int }
pts := []Point{{0,0}, {1,1}, {2,2}}
lom.Reverse(pts)
// pts -> []Point{{2,2}, {1,1}, {0,0}}