-
-
Notifications
You must be signed in to change notification settings - Fork 909
Open
Labels
breaking changeIntroduces changes that break backward compatibility or alter the public API.Introduces changes that break backward compatibility or alter the public API.specIssues related to writing, updating, or discussing project specifications or technical documentationIssues related to writing, updating, or discussing project specifications or technical documentation
Milestone
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:
intis simpleint64for larger collections (useless 99.9% of time)uint64the 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
Metadata
Metadata
Assignees
Labels
breaking changeIntroduces changes that break backward compatibility or alter the public API.Introduces changes that break backward compatibility or alter the public API.specIssues related to writing, updating, or discussing project specifications or technical documentationIssues related to writing, updating, or discussing project specifications or technical documentation