underscore/each.go
2022-03-29 08:26:35 -04:00

10 lines
252 B
Go

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