lo
lo copied to clipboard
[V2] index argument in methods with suffix Indexed
Current state:
Many methods are accepting iteratee as a function with 2 arguments func(item T, index int)
It's rather often that the index is not needed so the method that could be passed to Map, Filter, Reduce often ends up with with _ int as a second argument, just to match the function struct.
Proposition:
Rename all the current functions which accepts the index to XyzIndexed
Add functions without suffix Indexed which accepts similar function but without index argument.
From my experience the indexed version is rarely useful in comparison to func (item T). The latter allows you to use the existing function conveniently
lo.Map(foo, bar)
// vs
lo.Map(foo, func(item T, _ int) {
return bar(item)
})