aboutsummaryrefslogtreecommitdiff
path: root/core/testdata/format/website-html/newLinesInSamples.html
blob: 7e379c686d83360f14e39f5835deff1ec61967f6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
<div class='api-docs-breadcrumbs'><a href="../index.html">test</a> / <a href="./foo.html">foo</a></div>
<h1>foo</h1>
<div class="node-page-main" data-platform="" data-kotlin-version=""><div class="tags"><div class="spacer"></div>
<div class="tags__tag kotlin-version"></div>
</div>
<a name="$foo()"></a>
<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>
<div class="sample" data-min-compiler-version="1.3"><pre><code class="lang-kotlin">

fun main(args: Array&lt;String&gt;) {
//sampleStart
val words = listOf("a", "abc", "ab", "def", "abcd")
val byLength = words.groupBy { it.length }

println(byLength.keys) // [1, 3, 2, 4]
println(byLength.values) // [[a], [abc, def], [ab], [abcd]]

val mutableByLength: MutableMap&lt;Int, MutableList&lt;String&gt;&gt; = words.groupByTo(mutableMapOf()) { it.length }
// same content as in byLength map, but the map is mutable
println("mutableByLength == byLength is ${mutableByLength == byLength}") // true
//sampleEnd
}</code></pre></div>
</div>