-
Notifications
You must be signed in to change notification settings - Fork 87
Introduce a new associateBy() function #223
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add an entry to the changelog, although we should ponder if we want this, too...
Changelog entry added. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not convinced about the need for this function.
What are the already known use-cases that we are aiming to help?
lib/src/functions.dart
Outdated
} | ||
|
||
return map; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can be done using a map literal:
=> {for (var element in values) key(element): element};
and I think it should be.
@Kernald - are you still interested in this feature? |
@natebosch Sorry this kind of slipped out of my attention - I still think it would be nice to have. Should I go ahead and update the test as requested, and rename this as |
Yeah if you apply the feedback given so far we can do another round of review and keep this moving forward. Thanks for the contribution! If you need any help resolving merge conflicts or have any questions I can help. |
Rebased, and addressed the feedback:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very close now. Just need to mention the extension method in the CHANGELOG too.
Similar to groupBy(), except that it only keeps the latest value corresponding to a given key. Prior art: [Kotlin](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.sequences/associate-by.html)
Is there anything left preventing a merge? |
Similar to groupBy(), except that it only keeps the latest value corresponding to a given key. Prior art: [Kotlin](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.sequences/associate-by.html)
Similar to groupBy(), except that it only keeps the latest value corresponding to a given key.
Prior art: Kotlin