Passed
Pull Request — master (#93)
by Hayrullah
02:09
created

each.go   A

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 5
dl 0
loc 15
rs 10
c 0
b 0
f 0
1
package gotil
2
3
// Creates an array of values by running each element in the given array thru iteratee.
4
// The value to be iterated should be given as the first parameter.
5
// The second parameter will be a function that will take the parameter and return value type interface{}.
6
// 	gotil.Each([]string{"gotilty", "gotil"}, func(v string) {
7
// 	fmt.Fprint(os.Stdout, v)
8
// 	})
9
// 	// Output: gotiltygotil
10
11
func Each[T any](s []T, f func(v T)) {
12
	for _, v := range s {
13
		f(v)
14
	}
15
}
16