-
-
Notifications
You must be signed in to change notification settings - Fork 937
Closed
Description
Quite frequently, I want to do something like lo.Map(slice, Transformer) but Transformer returns (R, error).
I can write a function literal and handle the error, but it's still not ergonomic as there's no proper way to return the error.
So, I propose (and I can submit a PR for this) a variant of Map (and maybe others that make sense) that looks like this:
func Map[T any, R any](collection []T, iteratee func(T, int) (R, error)) ([]R, error)Where, if the iteratee returns an error, the entire iteration stops, returns an empty list and an error (or maybe returns what it has so far)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels