doesn’t provide simple way to return a mutable Map. doesn’t have valueTransform, so it changes the values by Grouping method such as eachCount(), fold(), reduce(), aggregate()….allows to pass a destination object to get mutable Map as result.Here are difference between groupBy and groupingBy method: Val byLength = oupBy )īoth groupBy & groupingBy help to group Collections and use selector as input parameter. To understand, please look at this example, we have a List of words, and what we need is to group them by their length (number of characters): val words = listOf("bezkoder", "zkoder", "kotlin", "programmingz", "bezcoder", "professional", "zcoder") In the Map, each key is the keySelector result and the corresponding value is the List of items on which this selector is returned. GroupBy() takes a selector and returns a Map.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |