Created
January 29, 2016 21:51
-
-
Save GrimTheReaper/df99f12dac5935cfe052 to your computer and use it in GitHub Desktop.
This file contains 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
package main | |
import "fmt" | |
func main() { | |
s := []string{"pig", "big", "sig", "pig", "lig", "tig", "pig", "sig", "kig", "pig"} | |
s = removeString(s, "pig") | |
fmt.Println(s) | |
} | |
func removeString(list []string, toRemove string) []string { | |
for i := 0; i < len(list); i++ { | |
if list[i] == toRemove { | |
list = append(list[:i], list[i+1:]...) | |
i-- | |
} | |
} | |
return list | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment