chunkedSequence

Splits this char sequence into a sequence of strings each not exceeding the given size.

The last string in the resulting sequence may have fewer characters than the given size.

Since Kotlin

1.2

Parameters

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.

Samples


fun <R> CharSequence.chunkedSequence(size: Int, transform: (CharSequence) -> R): Sequence<R>(source)

Splits this char sequence into several char sequences each not exceeding the given size and applies the given transform function to an each.

Since Kotlin

1.2

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 in some way, unless you made a snapshot of it. The last char sequence may have fewer characters than the given size.

Parameters

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.

Samples