Answers for "golang pop slice"

Go
2

go delete from slice

func remove(slice []int, s int) []int {
    return append(slice[:s], slice[s+1:]...)
}
Posted by: Guest on April-10-2020
0

go slice pop

// Pop last
slice := []int{1,2,3,4,5}
poppedVal := slice[len(slice)-1]
slice := slice[:len(a)-1]
fmt.Println(slice) // [1,2,3,4]
Posted by: Guest on May-12-2021

Browse Popular Code Answers by Language