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