lo icon indicating copy to clipboard operation
lo copied to clipboard

Porposal: provide functions without index such as Map

Open WingT opened this issue 2 years ago • 2 comments

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

WingT avatar Nov 28 '23 03:11 WingT

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 avatar Dec 08 '23 09:12 geritol

seems to be duplicate of https://github.com/samber/lo/issues/263

geritol avatar Dec 08 '23 09:12 geritol