1---
2title: foo - test
3layout: api
4---
5
6<div class='api-docs-breadcrumbs'><a href="test/index">test</a> / <a href="test/foo">foo</a></div>
7
8# foo
9
10<div class="signature"><code><span class="keyword">fun </span><span class="identifier">foo</span><span class="symbol">(</span><span class="symbol">)</span><span class="symbol">: </span><span class="identifier">Unit</span></code></div>
11<div class="sample" markdown="1">
12
13``` kotlin
14
15
16fun main(args: Array<String>) {
17//sampleStart
18val words = listOf("a", "abc", "ab", "def", "abcd")
19val byLength = words.groupBy { it.length }
20
21println(byLength.keys) // [1, 3, 2, 4]
22println(byLength.values) // [[a], [abc, def], [ab], [abcd]]
23
24val mutableByLength: MutableMap<Int, MutableList<String>> = words.groupByTo(mutableMapOf()) { it.length }
25// same content as in byLength map, but the map is mutable
26println("mutableByLength == byLength is ${mutableByLength == byLength}") // true
27//sampleEnd
28}
29```
30
31</div>
32