You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 index
lo.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 simple
int64 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.
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
-> indexThe
I
suffix might not be comprehensible. I would suggestWithIndex
as second choice.It might introduce a large breaking change because
Map
andFilter
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 typeDon't forget that passing a function to a helpers is a very developer-friendly API:
lo.Map(collection, aFunc)
. Sinceint
is the most used type it seems valuable to avoid any exotic typing and cast.Linking issues & PR: #565
The text was updated successfully, but these errors were encountered: