underscore/each.go
Ruidy 7d422c59d3
each (#10)
* feat: maps map

* : return initial slice

Co-authored-by: Ruidy <rnemausat@newstore.com>
2022-01-28 12:51:42 -04:00

10 lines
254 B
Go

package underscore
// Each iterates over a slice of elements, yielding each in turn to an action function.
// Returns the slice for chaining.
func Each[T any](values []T, action func(T)) []T {
for _, v := range values {
action(v)
}
return values
}