expression exclude fixed

This commit is contained in:
Pavel Vorobyov
2020-06-01 11:22:46 +03:00
parent f6ee512c95
commit 04e4442ac2
4 changed files with 95 additions and 31 deletions

View File

@@ -14,3 +14,11 @@ func Index(arr []string, item string) int {
func Contains(arr []string, item string) bool {
return Index(arr, item) >= 0
}
// Remove removes an item from array if it's in there
func Remove(arr *[]string, item string) {
idx := Index(*arr, item)
if idx >= 0 {
*arr = append((*arr)[0:idx], (*arr)[idx+1:len(*arr)]...)
}
}