| Total Lines | 15 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 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 |