What does it mean?

There is a line

books := append(books[:i], books[i+1:]...)

What does ... mean here?

You have a slice of books and you want to remove the element at position i


It is books = append( and not books := append( since you aren’t defining a new variable. books[:i] is the slice of books up to but not including the i:th element, and books[i+1:] is all books from i+1 to the end. The three dots at the end is spreading the elements of the slice as append wants the first element to be a slice of some type and an all the rest of the arguments as elements of that type. books[i+1:]… is like doing books[i+1], books[i+1 + 1], books[i+1 + 2] up to the last element.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.