Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

4
  • 5
    Noteworthy: Slice Tricks wiki page Commented Dec 12, 2013 at 15:45
  • I am trying to use this method on a slice of strings - I get this error: "cannot use m[i + 1:] (type []string) as type string in append" It seems to be expecting a string not a slice of strings as the second parameter. Any ideas? Commented Feb 9, 2015 at 15:46
  • 2
    Nvmd - I just realized that "..." was actually apart of the code. Commented Feb 9, 2015 at 16:08
  • 4
    If you use this while iterating m, you will get runtime error: slice bounds out of range. That's what this question is about. You can use m = append(m[:i], m[i+1:]...) to delete an item from a slice but not while you are iterating through it with for i, element := range m. Commented Aug 14, 2018 at 22:14