I was browsing around and found a question about grouping a String by it\'s characters, such as this:
String
The input:
\"aaabbbccccdd\" >
\"aaabbbccccdd\"
Take a look at
str.groupBy(identity)
which returns
scala.collection.immutable.Map[Char,String] = Map(b -> bbb, d -> dd, a -> aaa, c -> cccc)
so the key by which the elements are grouped by is the character.