The .classify method
%addrbook.classify({ .value.substr(0,1).uc })
- .classify
- applies the block to each element
- returns a list of pairs where
- keys are the values returned from applying the block
- values are arrays of values that produced that key
Example:
my %hash = @list.classify( { $_ % 2 ?? 'odd' !! 'even' } ); say %hash<even>.perl; # list of even elements in @list say %hash<odd>.perl; # list of odd elements in @list