Skip to content

Conversation

@maryum375
Copy link
Contributor

Implemented a new function to GroupBy.
This Implementation allows to map the values on the same iteration.
Sending an identity function as the iterateeValue will de facto result in a normal GroupBy operation.

Copy link
Owner

@samber samber left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think we need to think a little bit about the naming

your variant: map then group by

other cool variant I use in my own projects: map then group by then aggregate values

result := map[K][]V{}

for _, item := range arr {
k := iterateeKey(item)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would use a single iteratee: k, v := iteratee(item)

@samber samber changed the title Implemented GroupByMapValues Implemented GroupByMap Jan 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants