Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Porposal: provide functions without index such as Map #402

Open
WingT opened this issue Nov 28, 2023 · 2 comments
Open

Porposal: provide functions without index such as Map #402

WingT opened this issue Nov 28, 2023 · 2 comments

Comments

@WingT
Copy link

WingT commented Nov 28, 2023

I think in most cases we don't need the index parameter when calling functions such as lo.Map

@geritol
Copy link

geritol commented Dec 8, 2023

agree, it can provide much cleaner transformation functions also (if you have an fn for transforming the individual items).
ie.:

func transformList(ns []int) []string {
 // return lo.Map(ns, transform)
 return lo.Map(ns, func(item int, _ int) string {
    return transform(item)
  }
}

func transform(n int) string {
  return fmt.Sprintf("%d", n)
}

@geritol
Copy link

geritol commented Dec 8, 2023

seems to be duplicate of #263

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants