Skip to content

Instantly share code, notes, and snippets.

@rhysd rhysd/reverse.go

Created May 18, 2017
Embed
What would you like to do?
package main
func main() {
arr := []int{5, 4, 3, 2, 1}
l := len(arr)
for i, e := range arr[:l/2] {
j := l - 1 - i
arr[i] = arr[j]
arr[j] = e
}
for i, e := range arr {
if e != i+1 {
panic("oops")
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.