-
-
Notifications
You must be signed in to change notification settings - Fork 896
Open
Labels
Description
Go does not support optional arguments. We have to duplicate helpers if we want to make the index int
argument optional.
I'm opening this issue to discuss a new standard for naming helpers.
lo.Map(list, func(item T) U
-> no indexlo.MapI(list, func(item T, index int) U
-> index
The I
suffix might not be comprehensible. I would suggest WithIndex
as second choice.
It might introduce a large breaking change because Map
and Filter
are concerned. (see discussion about v2: #578)
Also, I wonder what would be the best type for this index:
int
is simpleint64
for larger collections (useless 99.9% of time)uint64
the most accurate type
Don't forget that passing a function to a helpers is a very developer-friendly API: lo.Map(collection, aFunc)
. Since int
is the most used type it seems valuable to avoid any exotic typing and cast.
Linking issues & PR: #565
Alucardik, sejin-P, askreet, lokshunhung, andrewbenington and 2 morezhulik, Alucardik, smbl64, askreet, andrewbenington and 1 more