How does Scala's groupBy identity work?

后端 未结 6 1043
天涯浪人
天涯浪人 2021-02-01 05:56

I was browsing around and found a question about grouping a String by it\'s characters, such as this:

The input:

\"aaabbbccccdd\"
         


        
6条回答
  •  挽巷
    挽巷 (楼主)
    2021-02-01 06:28

    Basically list.groupBy(identity) is just a fancy way of saying list.groupBy(x => x), which in my opinion is clearer. It groups a list containing duplicate items by those items.

提交回复
热议问题