3 ms·
You could make the same arguments when you're working with slices in Go. Take append(slice, element). Does it return a slice with the element appended to it, or
by Zababa 5y ago
You could make the same arguments when you're working with slices in Go. Take append(slice, element). Does it return a slice with the element appended to it, or does it modify the slice in-place?. For some things, you have to look at the docs, that's how it is. Usually languages have conventions around that. In JS, map, filter and reduce always return a fresh array and leave the initial array untouched.
- masklinn 5y ago> You could make the same arguments when you're working with slices in Go. Take append(slice, element). Does it return a slice with the element appended to it, or does it modify the slice in-place? A funny trick question as it pretty much does both. Also I'll take "functional trickery" over needing a page called Slice Tricks so you can find out how to delete an item any day of the week.