[
https://issues.apache.org/jira/browse/GROOVY-11808?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18041624#comment-18041624
]
Paul King commented on GROOVY-11808:
------------------------------------
[~emilles] Just saw your message. "groupBy" has a function that returns a
single key. "groupByMany" has a function that returns a list of keys. Grouped
items are by key but items with common keys are coalesced into a list.
{code:groovy}
var words = ['ant', 'bee', 'ape', 'cow', 'pig']
var vowels = 'aeiou'.toSet()
var vowelsOf = { String word -> word.toSet().intersect(vowels).toList() }
assert words.groupBy(s -> vowelsOf(s)) == [
['a']:['ant'], ['e']:['bee'], ['a', 'e']:['ape'], ['o']:['cow'],
['i']:['pig']
]
assert words.groupByMany(s -> vowelsOf(s)) == [
a:['ant', 'ape'], e:['bee', 'ape'], i:['pig'], o:['cow']
]
{code}
The change is just in Groovy 6 and no release is planned just yet. I'll tweak
to cover the other items.
> create a DGM#groupByMany extension method
> -----------------------------------------
>
> Key: GROOVY-11808
> URL: https://issues.apache.org/jira/browse/GROOVY-11808
> Project: Groovy
> Issue Type: New Feature
> Reporter: Paul King
> Assignee: Paul King
> Priority: Major
> Fix For: 6.0.0-alpha-1
>
>
--
This message was sent by Atlassian Jira
(v8.20.10#820010)