Created
October 26, 2017 00:39
-
-
Save lamarmarshall/1252260bb938dcd2a3f64cb20029f956 to your computer and use it in GitHub Desktop.
go delete element from slice
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
delete := func(a []int, index int) []int { | |
last := index + 1 | |
a = append(a[:index], a[last:]...) | |
return a | |
} | |
fmt.Println("deleted ", delete(sls, 2)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment