From b2f2e3537b06767c2b9239546320195093a8fa65 Mon Sep 17 00:00:00 2001 From: Ilya Gorbunov Date: Tue, 16 May 2017 23:53:46 +0300 Subject: [PATCH] Docs and samples for 'chunked' function --- .../src/core/generated/_CollectionsJs.kt | 23 ++++++ .../src/core/generated/_SequencesJs.kt | 27 +++++++ .../src/core/generated/_StringsJs.kt | 46 +++++++++++ .../common/src/generated/_Collections.kt | 23 ++++++ .../stdlib/common/src/generated/_Sequences.kt | 27 +++++++ .../stdlib/common/src/generated/_Strings.kt | 46 +++++++++++ .../test/samples/collections/collections.kt | 9 +++ .../samples/test/samples/text/strings.kt | 20 +++++ .../stdlib/src/generated/_Collections.kt | 23 ++++++ libraries/stdlib/src/generated/_Sequences.kt | 27 +++++++ libraries/stdlib/src/generated/_Strings.kt | 46 +++++++++++ .../src/templates/Generators.kt | 76 ++++++++++++++++++- 12 files changed, 391 insertions(+), 2 deletions(-) diff --git a/js/js.libraries/src/core/generated/_CollectionsJs.kt b/js/js.libraries/src/core/generated/_CollectionsJs.kt index ff67ac709fb..cab3f1b5226 100644 --- a/js/js.libraries/src/core/generated/_CollectionsJs.kt +++ b/js/js.libraries/src/core/generated/_CollectionsJs.kt @@ -1788,11 +1788,34 @@ public fun List.requireNoNulls(): List { return this as List } +/** + * Splits this collection into a list of lists each not exceeding the given [size]. + * + * The last list in the resulting list may have less elements than the given [size]. + * + * @param size the number of elements to take in each list, must be positive and can be greater than the number of elements in this collection. + * + * @sample samples.collections.Collections.Transformations.chunked + */ @SinceKotlin("1.2") public fun Iterable.chunked(size: Int): List> { return windowed(size, size) } +/** + * Splits this collection into several lists each not exceeding the given [size] + * and applies the given [transform] function to an each. + * + * @return list of results of the [transform] applied to an each list. + * + * Note that the list passed to the [transform] function is ephemeral and is valid only inside that function. + * You should not store it or allow it escape someway, unless you made a snapshot of it. + * The last list may have less elements than the given [size]. + * + * @param size the number of elements to take in each list, must be positive and can be greater than the number of elements in this collection. + * + * @sample samples.text.Strings.chunkedTransform + */ @SinceKotlin("1.2") public fun Iterable.chunked(size: Int, transform: (List) -> R): List { return windowed(size, size, transform) diff --git a/js/js.libraries/src/core/generated/_SequencesJs.kt b/js/js.libraries/src/core/generated/_SequencesJs.kt index d49e53b12f5..1fabbeacff7 100644 --- a/js/js.libraries/src/core/generated/_SequencesJs.kt +++ b/js/js.libraries/src/core/generated/_SequencesJs.kt @@ -1309,11 +1309,38 @@ public fun Sequence.requireNoNulls(): Sequence { return map { it ?: throw IllegalArgumentException("null element found in $this.") } } +/** + * Splits this sequence into a sequence of lists each not exceeding the given [size]. + * + * The last list in the resulting sequence may have less elements than the given [size]. + * + * @param size the number of elements to take in each list, must be positive and can be greater than the number of elements in this sequence. + * + * @sample samples.collections.Collections.Transformations.chunked + * + * The operation is _intermediate_ and _stateful_. + */ @SinceKotlin("1.2") public fun Sequence.chunked(size: Int): Sequence> { return windowed(size, size) } +/** + * Splits this sequence into several lists each not exceeding the given [size] + * and applies the given [transform] function to an each. + * + * @return sequence of results of the [transform] applied to an each list. + * + * Note that the list passed to the [transform] function is ephemeral and is valid only inside that function. + * You should not store it or allow it escape someway, unless you made a snapshot of it. + * The last list may have less elements than the given [size]. + * + * @param size the number of elements to take in each list, must be positive and can be greater than the number of elements in this sequence. + * + * @sample samples.text.Strings.chunkedTransform + * + * The operation is _intermediate_ and _stateful_. + */ @SinceKotlin("1.2") public fun Sequence.chunked(size: Int, transform: (List) -> R): Sequence { return windowed(size, size, transform) diff --git a/js/js.libraries/src/core/generated/_StringsJs.kt b/js/js.libraries/src/core/generated/_StringsJs.kt index 12e168f46d5..50b91464962 100644 --- a/js/js.libraries/src/core/generated/_StringsJs.kt +++ b/js/js.libraries/src/core/generated/_StringsJs.kt @@ -1102,21 +1102,67 @@ public inline fun CharSequence.sumByDouble(selector: (Char) -> Double): Double { return sum } +/** + * Splits this char sequence into a list of strings each not exceeding the given [size]. + * + * The last string in the resulting list may have less characters than the given [size]. + * + * @param size the number of elements to take in each string, must be positive and can be greater than the number of elements in this char sequence. + * + * @sample samples.collections.Collections.Transformations.chunked + */ @SinceKotlin("1.2") public fun CharSequence.chunked(size: Int): List { return windowed(size, size) } +/** + * Splits this char sequence into several char sequences each not exceeding the given [size] + * and applies the given [transform] function to an each. + * + * @return list of results of the [transform] applied to an each char sequence. + * + * Note that the char sequence passed to the [transform] function is ephemeral and is valid only inside that function. + * You should not store it or allow it escape someway, unless you made a snapshot of it. + * The last char sequence may have less characters than the given [size]. + * + * @param size the number of elements to take in each char sequence, must be positive and can be greater than the number of elements in this char sequence. + * + * @sample samples.text.Strings.chunkedTransform + */ @SinceKotlin("1.2") public fun CharSequence.chunked(size: Int, transform: (CharSequence) -> R): List { return windowed(size, size, transform) } +/** + * Splits this char sequence into a sequence of strings each not exceeding the given [size]. + * + * The last string in the resulting sequence may have less characters than the given [size]. + * + * @param size the number of elements to take in each string, must be positive and can be greater than the number of elements in this char sequence. + * + * @sample samples.collections.Collections.Transformations.chunked + */ @SinceKotlin("1.2") public fun CharSequence.chunkedSequence(size: Int): Sequence { return chunkedSequence(size) { it.toString() } } +/** + * Splits this char sequence into several char sequences each not exceeding the given [size] + * and applies the given [transform] function to an each. + * + * @return sequence of results of the [transform] applied to an each char sequence. + * + * Note that the char sequence passed to the [transform] function is ephemeral and is valid only inside that function. + * You should not store it or allow it to escape someway, unless you made a snapshot of it. + * The last char sequence may have less characters than the given [size]. + * + * @param size the number of elements to take in each char sequence, must be positive and can be greater than the number of elements in this char sequence. + * + * @sample samples.text.Strings.chunkedTransformToSequence + */ @SinceKotlin("1.2") public fun CharSequence.chunkedSequence(size: Int, transform: (CharSequence) -> R): Sequence { return windowedSequence(size, size, transform) diff --git a/libraries/stdlib/common/src/generated/_Collections.kt b/libraries/stdlib/common/src/generated/_Collections.kt index 525a0ee235d..b018f4522e6 100644 --- a/libraries/stdlib/common/src/generated/_Collections.kt +++ b/libraries/stdlib/common/src/generated/_Collections.kt @@ -898,9 +898,32 @@ public expect fun Iterable.requireNoNulls(): Iterable */ public expect fun List.requireNoNulls(): List +/** + * Splits this collection into a list of lists each not exceeding the given [size]. + * + * The last list in the resulting list may have less elements than the given [size]. + * + * @param size the number of elements to take in each list, must be positive and can be greater than the number of elements in this collection. + * + * @sample samples.collections.Collections.Transformations.chunked + */ @SinceKotlin("1.2") public expect fun Iterable.chunked(size: Int): List> +/** + * Splits this collection into several lists each not exceeding the given [size] + * and applies the given [transform] function to an each. + * + * @return list of results of the [transform] applied to an each list. + * + * Note that the list passed to the [transform] function is ephemeral and is valid only inside that function. + * You should not store it or allow it escape someway, unless you made a snapshot of it. + * The last list may have less elements than the given [size]. + * + * @param size the number of elements to take in each list, must be positive and can be greater than the number of elements in this collection. + * + * @sample samples.text.Strings.chunkedTransform + */ @SinceKotlin("1.2") public expect fun Iterable.chunked(size: Int, transform: (List) -> R): List diff --git a/libraries/stdlib/common/src/generated/_Sequences.kt b/libraries/stdlib/common/src/generated/_Sequences.kt index 0edd231fdaa..d127889d43d 100644 --- a/libraries/stdlib/common/src/generated/_Sequences.kt +++ b/libraries/stdlib/common/src/generated/_Sequences.kt @@ -803,9 +803,36 @@ public expect inline fun Sequence.sumByDouble(selector: (T) -> Double): D */ public expect fun Sequence.requireNoNulls(): Sequence +/** + * Splits this sequence into a sequence of lists each not exceeding the given [size]. + * + * The last list in the resulting sequence may have less elements than the given [size]. + * + * @param size the number of elements to take in each list, must be positive and can be greater than the number of elements in this sequence. + * + * @sample samples.collections.Collections.Transformations.chunked + * + * The operation is _intermediate_ and _stateful_. + */ @SinceKotlin("1.2") public expect fun Sequence.chunked(size: Int): Sequence> +/** + * Splits this sequence into several lists each not exceeding the given [size] + * and applies the given [transform] function to an each. + * + * @return sequence of results of the [transform] applied to an each list. + * + * Note that the list passed to the [transform] function is ephemeral and is valid only inside that function. + * You should not store it or allow it escape someway, unless you made a snapshot of it. + * The last list may have less elements than the given [size]. + * + * @param size the number of elements to take in each list, must be positive and can be greater than the number of elements in this sequence. + * + * @sample samples.text.Strings.chunkedTransform + * + * The operation is _intermediate_ and _stateful_. + */ @SinceKotlin("1.2") public expect fun Sequence.chunked(size: Int, transform: (List) -> R): Sequence diff --git a/libraries/stdlib/common/src/generated/_Strings.kt b/libraries/stdlib/common/src/generated/_Strings.kt index 19c4fab28de..24ee56e08f8 100644 --- a/libraries/stdlib/common/src/generated/_Strings.kt +++ b/libraries/stdlib/common/src/generated/_Strings.kt @@ -638,15 +638,61 @@ public expect inline fun CharSequence.sumBy(selector: (Char) -> Int): Int */ public expect inline fun CharSequence.sumByDouble(selector: (Char) -> Double): Double +/** + * Splits this char sequence into a list of strings each not exceeding the given [size]. + * + * The last string in the resulting list may have less characters than the given [size]. + * + * @param size the number of elements to take in each string, must be positive and can be greater than the number of elements in this char sequence. + * + * @sample samples.collections.Collections.Transformations.chunked + */ @SinceKotlin("1.2") public expect fun CharSequence.chunked(size: Int): List +/** + * Splits this char sequence into several char sequences each not exceeding the given [size] + * and applies the given [transform] function to an each. + * + * @return list of results of the [transform] applied to an each char sequence. + * + * Note that the char sequence passed to the [transform] function is ephemeral and is valid only inside that function. + * You should not store it or allow it escape someway, unless you made a snapshot of it. + * The last char sequence may have less characters than the given [size]. + * + * @param size the number of elements to take in each char sequence, must be positive and can be greater than the number of elements in this char sequence. + * + * @sample samples.text.Strings.chunkedTransform + */ @SinceKotlin("1.2") public expect fun CharSequence.chunked(size: Int, transform: (CharSequence) -> R): List +/** + * Splits this char sequence into a sequence of strings each not exceeding the given [size]. + * + * The last string in the resulting sequence may have less characters than the given [size]. + * + * @param size the number of elements to take in each string, must be positive and can be greater than the number of elements in this char sequence. + * + * @sample samples.collections.Collections.Transformations.chunked + */ @SinceKotlin("1.2") public expect fun CharSequence.chunkedSequence(size: Int): Sequence +/** + * Splits this char sequence into several char sequences each not exceeding the given [size] + * and applies the given [transform] function to an each. + * + * @return sequence of results of the [transform] applied to an each char sequence. + * + * Note that the char sequence passed to the [transform] function is ephemeral and is valid only inside that function. + * You should not store it or allow it to escape someway, unless you made a snapshot of it. + * The last char sequence may have less characters than the given [size]. + * + * @param size the number of elements to take in each char sequence, must be positive and can be greater than the number of elements in this char sequence. + * + * @sample samples.text.Strings.chunkedTransformToSequence + */ @SinceKotlin("1.2") public expect fun CharSequence.chunkedSequence(size: Int, transform: (CharSequence) -> R): Sequence diff --git a/libraries/stdlib/samples/test/samples/collections/collections.kt b/libraries/stdlib/samples/test/samples/collections/collections.kt index f70014fbbfd..57e1112d629 100644 --- a/libraries/stdlib/samples/test/samples/collections/collections.kt +++ b/libraries/stdlib/samples/test/samples/collections/collections.kt @@ -71,6 +71,15 @@ class Collections { assertPrints(moreFrequencies, "{o=1, t=4, f=2, s=2, e=2, n=1}") } + @Sample + fun chunked() { + val words = "one two three four five six seven eight nine ten".split(' ') + val chunks = words.chunked(3) + + assertPrints(chunks, "[[one, two, three], [four, five, six], [seven, eight, nine], [ten]]") + } + + @Sample fun pairwise() { val letters = ('a'..'f').toList() diff --git a/libraries/stdlib/samples/test/samples/text/strings.kt b/libraries/stdlib/samples/test/samples/text/strings.kt index bf48381cd19..075b99746b8 100644 --- a/libraries/stdlib/samples/test/samples/text/strings.kt +++ b/libraries/stdlib/samples/test/samples/text/strings.kt @@ -50,5 +50,25 @@ class Strings { assertPrints(withoutMargin2, "XYZ\nfoo\nbar") } + @Sample + fun chunkedTransform() { + val codonTable = mapOf("ATT" to "Isoleucine", "CAA" to "Glutamine", "CGC" to "Arginine", "GGC" to "Glycine") + val dnaFragment = "ATTCGCGGCCGCCAA" + + val proteins = dnaFragment.chunked(3) { codon: CharSequence -> codonTable[codon.toString()] ?: error("Unknown codon") } + + assertPrints(proteins, "[Isoleucine, Arginine, Glycine, Arginine, Glutamine]") + } + + @Sample + fun chunkedTransformToSequence() { + val codonTable = mapOf("ATT" to "Isoleucine", "CAA" to "Glutamine", "CGC" to "Arginine", "GGC" to "Glycine") + val dnaFragment = "ATTCGCGGCCGCCAACGG" + + val proteins = dnaFragment.chunkedSequence(3) { codon: CharSequence -> codonTable[codon.toString()] ?: error("Unknown codon") } + + // sequence is evaluated lazily, so that unknown codon is not reached + assertPrints(proteins.take(5).toList(), "[Isoleucine, Arginine, Glycine, Arginine, Glutamine]") + } } diff --git a/libraries/stdlib/src/generated/_Collections.kt b/libraries/stdlib/src/generated/_Collections.kt index 0394c517eed..badd7579eac 100644 --- a/libraries/stdlib/src/generated/_Collections.kt +++ b/libraries/stdlib/src/generated/_Collections.kt @@ -1798,11 +1798,34 @@ public fun List.requireNoNulls(): List { return this as List } +/** + * Splits this collection into a list of lists each not exceeding the given [size]. + * + * The last list in the resulting list may have less elements than the given [size]. + * + * @param size the number of elements to take in each list, must be positive and can be greater than the number of elements in this collection. + * + * @sample samples.collections.Collections.Transformations.chunked + */ @SinceKotlin("1.2") public fun Iterable.chunked(size: Int): List> { return windowed(size, size) } +/** + * Splits this collection into several lists each not exceeding the given [size] + * and applies the given [transform] function to an each. + * + * @return list of results of the [transform] applied to an each list. + * + * Note that the list passed to the [transform] function is ephemeral and is valid only inside that function. + * You should not store it or allow it escape someway, unless you made a snapshot of it. + * The last list may have less elements than the given [size]. + * + * @param size the number of elements to take in each list, must be positive and can be greater than the number of elements in this collection. + * + * @sample samples.text.Strings.chunkedTransform + */ @SinceKotlin("1.2") public fun Iterable.chunked(size: Int, transform: (List) -> R): List { return windowed(size, size, transform) diff --git a/libraries/stdlib/src/generated/_Sequences.kt b/libraries/stdlib/src/generated/_Sequences.kt index 425f2eabf32..242ff6def75 100644 --- a/libraries/stdlib/src/generated/_Sequences.kt +++ b/libraries/stdlib/src/generated/_Sequences.kt @@ -1331,11 +1331,38 @@ public fun Sequence.requireNoNulls(): Sequence { return map { it ?: throw IllegalArgumentException("null element found in $this.") } } +/** + * Splits this sequence into a sequence of lists each not exceeding the given [size]. + * + * The last list in the resulting sequence may have less elements than the given [size]. + * + * @param size the number of elements to take in each list, must be positive and can be greater than the number of elements in this sequence. + * + * @sample samples.collections.Collections.Transformations.chunked + * + * The operation is _intermediate_ and _stateful_. + */ @SinceKotlin("1.2") public fun Sequence.chunked(size: Int): Sequence> { return windowed(size, size) } +/** + * Splits this sequence into several lists each not exceeding the given [size] + * and applies the given [transform] function to an each. + * + * @return sequence of results of the [transform] applied to an each list. + * + * Note that the list passed to the [transform] function is ephemeral and is valid only inside that function. + * You should not store it or allow it escape someway, unless you made a snapshot of it. + * The last list may have less elements than the given [size]. + * + * @param size the number of elements to take in each list, must be positive and can be greater than the number of elements in this sequence. + * + * @sample samples.text.Strings.chunkedTransform + * + * The operation is _intermediate_ and _stateful_. + */ @SinceKotlin("1.2") public fun Sequence.chunked(size: Int, transform: (List) -> R): Sequence { return windowed(size, size, transform) diff --git a/libraries/stdlib/src/generated/_Strings.kt b/libraries/stdlib/src/generated/_Strings.kt index 0ee1a6bb676..1315c57a9d1 100644 --- a/libraries/stdlib/src/generated/_Strings.kt +++ b/libraries/stdlib/src/generated/_Strings.kt @@ -1110,21 +1110,67 @@ public inline fun CharSequence.sumByDouble(selector: (Char) -> Double): Double { return sum } +/** + * Splits this char sequence into a list of strings each not exceeding the given [size]. + * + * The last string in the resulting list may have less characters than the given [size]. + * + * @param size the number of elements to take in each string, must be positive and can be greater than the number of elements in this char sequence. + * + * @sample samples.collections.Collections.Transformations.chunked + */ @SinceKotlin("1.2") public fun CharSequence.chunked(size: Int): List { return windowed(size, size) } +/** + * Splits this char sequence into several char sequences each not exceeding the given [size] + * and applies the given [transform] function to an each. + * + * @return list of results of the [transform] applied to an each char sequence. + * + * Note that the char sequence passed to the [transform] function is ephemeral and is valid only inside that function. + * You should not store it or allow it escape someway, unless you made a snapshot of it. + * The last char sequence may have less characters than the given [size]. + * + * @param size the number of elements to take in each char sequence, must be positive and can be greater than the number of elements in this char sequence. + * + * @sample samples.text.Strings.chunkedTransform + */ @SinceKotlin("1.2") public fun CharSequence.chunked(size: Int, transform: (CharSequence) -> R): List { return windowed(size, size, transform) } +/** + * Splits this char sequence into a sequence of strings each not exceeding the given [size]. + * + * The last string in the resulting sequence may have less characters than the given [size]. + * + * @param size the number of elements to take in each string, must be positive and can be greater than the number of elements in this char sequence. + * + * @sample samples.collections.Collections.Transformations.chunked + */ @SinceKotlin("1.2") public fun CharSequence.chunkedSequence(size: Int): Sequence { return chunkedSequence(size) { it.toString() } } +/** + * Splits this char sequence into several char sequences each not exceeding the given [size] + * and applies the given [transform] function to an each. + * + * @return sequence of results of the [transform] applied to an each char sequence. + * + * Note that the char sequence passed to the [transform] function is ephemeral and is valid only inside that function. + * You should not store it or allow it to escape someway, unless you made a snapshot of it. + * The last char sequence may have less characters than the given [size]. + * + * @param size the number of elements to take in each char sequence, must be positive and can be greater than the number of elements in this char sequence. + * + * @sample samples.text.Strings.chunkedTransformToSequence + */ @SinceKotlin("1.2") public fun CharSequence.chunkedSequence(size: Int, transform: (CharSequence) -> R): Sequence { return windowedSequence(size, size, transform) diff --git a/libraries/tools/kotlin-stdlib-gen/src/templates/Generators.kt b/libraries/tools/kotlin-stdlib-gen/src/templates/Generators.kt index b72ed48710a..4585e34a81a 100644 --- a/libraries/tools/kotlin-stdlib-gen/src/templates/Generators.kt +++ b/libraries/tools/kotlin-stdlib-gen/src/templates/Generators.kt @@ -673,12 +673,29 @@ fun generators(): List { templates add f("chunked(size: Int, transform: (List) -> R)") { since("1.2") only(Iterables, Sequences, CharSequences) - typeParam("R") + doc { f -> + """ + Splits this ${f.collection} into several ${f.viewResult.pluralize()} each not exceeding the given [size] + and applies the given [transform] function to an each. + @return ${f.mapResult} of results of the [transform] applied to an each ${f.viewResult}. + + Note that the ${f.viewResult} passed to the [transform] function is ephemeral and is valid only inside that function. + You should not store it or allow it escape someway, unless you made a snapshot of it. + The last ${f.viewResult} may have less ${f.element.pluralize()} than the given [size]. + + @param size the number of elements to take in each ${f.viewResult}, must be positive and can be greater than the number of elements in this ${f.collection}. + + @sample samples.text.Strings.chunkedTransform + """ + } + + typeParam("R") returns("List") customSignature(CharSequences) { "chunked(size: Int, transform: (CharSequence) -> R)" } + sequenceClassification(intermediate, stateful) returns(Sequences) { "Sequence" } body { "return windowed(size, size, transform)" } } @@ -686,16 +703,46 @@ fun generators(): List { templates add f("chunked(size: Int)") { since("1.2") only(Iterables, Sequences, CharSequences) + doc { f -> + """ + Splits this ${f.collection} into a ${f.mapResult} of ${f.snapshotResult.pluralize()} each not exceeding the given [size]. + + The last ${f.snapshotResult} in the resulting ${f.mapResult} may have less ${f.element.pluralize()} than the given [size]. + + @param size the number of elements to take in each ${f.snapshotResult}, must be positive and can be greater than the number of elements in this ${f.collection}. + + @sample samples.collections.Collections.Transformations.chunked + """ + } returns(Iterables) { "List>" } returns(Sequences) { "Sequence>" } returns(CharSequences) { "List" } + sequenceClassification(intermediate, stateful) + body { "return windowed(size, size)" } } templates add f("chunkedSequence(size: Int, transform: (CharSequence) -> R)") { since("1.2") only(CharSequences) + doc { f -> + """ + Splits this ${f.collection} into several ${f.viewResult.pluralize()} each not exceeding the given [size] + and applies the given [transform] function to an each. + + @return sequence of results of the [transform] applied to an each ${f.viewResult}. + + Note that the ${f.viewResult} passed to the [transform] function is ephemeral and is valid only inside that function. + You should not store it or allow it to escape someway, unless you made a snapshot of it. + The last ${f.viewResult} may have less ${f.element.pluralize()} than the given [size]. + + @param size the number of elements to take in each ${f.viewResult}, must be positive and can be greater than the number of elements in this ${f.collection}. + + @sample samples.text.Strings.chunkedTransformToSequence + """ + } + typeParam("R") returns { "Sequence "} @@ -709,6 +756,17 @@ fun generators(): List { templates add f("chunkedSequence(size: Int)") { since("1.2") only(CharSequences) + doc { f -> + """ + Splits this ${f.collection} into a sequence of ${f.snapshotResult.pluralize()} each not exceeding the given [size]. + + The last ${f.snapshotResult} in the resulting sequence may have less ${f.element.pluralize()} than the given [size]. + + @param size the number of elements to take in each ${f.snapshotResult}, must be positive and can be greater than the number of elements in this ${f.collection}. + + @sample samples.collections.Collections.Transformations.chunked + """ + } returns { "Sequence "} body(CharSequences) { "return chunkedSequence(size) { it.toString() }" } @@ -1017,4 +1075,18 @@ fun generators(): List { } return templates -} \ No newline at end of file +} + +// documentation helpers + +private val Family.snapshotResult: String + get() = when (this) { + CharSequences, Strings -> "string" + else -> "list" + } + +private val Family.viewResult: String + get() = when (this) { + CharSequences, Strings -> "char sequence" + else -> "list" + }