underscore/each.go
Ruidy f6af583408
Pipe (#26)
* rename to pipe

* add security scan

* use var in Makefile
2022-03-31 17:37:02 +02: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
}