Skip to content

Add support for optional mapper in toSet() and toList()#27

Merged
thekid merged 2 commits intomasterfrom
feature/set-and-list-with-map
Nov 23, 2015
Merged

Add support for optional mapper in toSet() and toList()#27
thekid merged 2 commits intomasterfrom
feature/set-and-list-with-map

Conversation

@thekid
Copy link
Member

@thekid thekid commented Nov 23, 2015

This makes these two methods consistent with toMap(). This comes in handy when using Collectors::toX() in conjunction with grouping:

$namesByDepartment= Sequence::of($this->employees)
  ->collect(Collectors::groupingBy(
    function($e) { return $e->department()->name(); },
    Collectors::toList(function($e) { return $e->name(); })
  ))
;

// = [
//  'System Administration' => ['Jon', 'Paul'],
//  'Infrastructure Development' => ['Ben', 'The Dude']
// ]

thekid added a commit that referenced this pull request Nov 23, 2015
Add support for optional mapper in toSet() and toList()
@thekid thekid merged commit 91598e1 into master Nov 23, 2015
@thekid thekid deleted the feature/set-and-list-with-map branch November 23, 2015 18:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant