Skip to content
Snippets Groups Projects
Commit 856278ab authored by Johan de Klerk's avatar Johan de Klerk
Browse files

slice utils: Filter out empty values

parent 09b84c4a
No related branches found
No related tags found
No related merge requests found
......@@ -37,3 +37,19 @@ func ElementExists(in interface{}, elem interface{}) (bool, int) {
idx := funk.IndexOf(in, elem)
return idx != -1, idx
}
func FilterNonZero(arr []int64) []int64 {
// Filter out the zero numbers
nonZeroNumbers := funk.Filter(arr, func(number int64) bool {
return number != 0
}).([]int64)
return nonZeroNumbers
}
func FilterNonEmptyString(arr []string) []string {
// Filter out empty strings
nonEmptyStrings := funk.Filter(arr, func(value string) bool {
return value != ""
}).([]string)
return nonEmptyStrings
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment