Skip to content

Implemented GroupByMap#443

Merged
samber merged 1 commit into
samber:masterfrom
maryum375:master
Jan 28, 2025
Merged

Implemented GroupByMap#443
samber merged 1 commit into
samber:masterfrom
maryum375:master

Conversation

@maryum375
Copy link
Copy Markdown
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
Copy Markdown
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

Comment thread slice.go
result := map[K][]V{}

for _, item := range arr {
k := iterateeKey(item)
Copy link
Copy Markdown
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