1<div class='api-docs-breadcrumbs'><a href="index.html">test</a> / <a href="./foo.html">foo</a></div> 2<h1>foo</h1> 3<a name="$foo()"></a> 4<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> 5<div class="sample"><pre><code class="lang-kotlin"> 6 7fun main(args: Array<String>) { 8//sampleStart 9val words = listOf("a", "abc", "ab", "def", "abcd") 10val byLength = words.groupBy { it.length } 11 12println(byLength.keys) // [1, 3, 2, 4] 13println(byLength.values) // [[a], [abc, def], [ab], [abcd]] 14 15val mutableByLength: MutableMap<Int, MutableList<String>> = words.groupByTo(mutableMapOf()) { it.length } 16// same content as in byLength map, but the map is mutable 17println("mutableByLength == byLength is ${mutableByLength == byLength}") // true 18//sampleEnd 19}</code></pre></div> 20