Update example for default buildList to not use capacity KT-41136 (#3688)

This commit is contained in:
Derek Bodin
2020-10-14 17:56:57 -05:00
committed by GitHub
parent d9b3f91d73
commit 96834d6f4c
2 changed files with 14 additions and 1 deletions
@@ -9,6 +9,19 @@ class Builders {
fun buildListSample() {
val x = listOf('b', 'c')
val y = buildList() {
add('a')
addAll(x)
add('d')
}
assertPrints(y, "[a, b, c, d]")
}
@Sample
fun buildListSampleWithCapacity() {
val x = listOf('b', 'c')
val y = buildList(x.size + 2) {
add('a')
addAll(x)
@@ -189,7 +189,7 @@ internal expect inline fun <E> buildListInternal(builderAction: MutableList<E>.(
*
* @throws IllegalArgumentException if the given [capacity] is negative.
*
* @sample samples.collections.Builders.Lists.buildListSample
* @sample samples.collections.Builders.Lists.buildListSampleWithCapacity
*/
@SinceKotlin("1.3")
@ExperimentalStdlibApi