Passed
Pull Request — master (#66)
by Hayrullah
56s
created

filter.go   A

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 4
dl 0
loc 15
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A gotil.FilterBy 0 2 1
1
package gotil
2
3
import "github.com/gotilty/gotil/internal"
4
5
// FilterBy iterates over elements of collection, returning an array of all elements predicate if returns true for.
6
// 		newData, _ := FilterBy([]int64{-100, -5, 30, 100}, func(val interface{}, i int) bool {
7
// 			if val.(int64) > 0 {
8
// 				return true
9
// 			} else {
10
// 				return false
11
// 			}
12
// 		})
13
// 		// Output: [30 100]
14
func FilterBy(a interface{}, f func(val interface{}, i int) bool) (interface{}, error) {
15
	return internal.FilterBy(a, f)
16
}
17