3 ms·
That's the most compelling example you could come up with as someone who presumably writes Go? Reversing a slice of T. Copy and pasting this: for i := len
by hombre_fatal 6y ago
That's the most compelling example you could come up with as someone who presumably writes Go?
Reversing a slice of T. Copy and pasting this:
for i := len(a)/2 - 1; i >= 0; i-- {
opp := len(a) - 1 - i
a[i], a[opp] = a[opp], a[i]
}
New:
reverse(a)
Or generic versions of these: https://gobyexample.com/collection-functions https://gobyexample.com/collection-functions
- adamch 6y agoYep, this is exactly the use case I was talking about.