I wrote a very small prepend function for go.
func prepend(slice []int, elms ... int) []int { newSlice := []int{} for _, elm := range elms { newSlice = append(newSlice, elm) } for _, item := range slice { newSlice = append(newSlice, item) } return newSlice }
In any case, to make a function common to any type?
So, I can add a piece of arrays to it.
Also, is there a better way to write this function?
I did not find anything on the Internet about writing.
go
Ben
source share