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

gotil.FilterBy   A

Complexity

Conditions 1

Size

Total Lines 2
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
dl 0
loc 2
rs 10
c 0
b 0
f 0
nop 2
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