Quick actions

cmd+k|ctrl+k

Navigation

Languages

Slices / Remove elements from slice / Essential Go

Snippet info

Language

Go

Visibility

public

Author

kkowalczyk

Created

2019-04-18T17:11:20Z

Updated

2019-04-18T17:11:20Z

package main

import "fmt"

func main() {
	s := []int{10, 11, 12, 13}

	i := 1 // index of 11
	n := 2 // remove 2 elements

	s = append(s[:i], s[i+n:]...)

	fmt.Printf("s: %#v\n", s)
}
INFO