joinTo

inline fun <I, R> Iterable<I>.joinTo(separatorFun: (I) -> R?, prefix: R? = null, postfix: R? = null, transform: (I) -> R?): List<R>(source)

Joins elements of this iterable into a list with separators between elements. Each element is transformed using transform, and separators are generated using separatorFun. Optional prefix and postfix can be added to the result. Null values from transformations or separator function are skipped.

Return

A list of transformed elements with separators

Parameters

separatorFun

A function that generates a separator based on the current element

prefix

Optional prefix to add at the beginning of the result

postfix

Optional postfix to add at the end of the result

transform

A function to transform each element

Type Parameters

I

The type of elements in the input iterable

R

The type of elements in the result list


inline fun <I, R> Iterable<I>.joinTo(separator: R? = null, prefix: R? = null, postfix: R? = null, transform: (I) -> R?): List<R>(source)

Joins elements of this iterable into a list with a constant separator between elements. Each element is transformed using transform. Optional prefix and postfix can be added to the result. Null values from transformations or separators are skipped.

Return

A list of transformed elements with separators

Parameters

separator

The separator to insert between elements

prefix

Optional prefix to add at the beginning of the result

postfix

Optional postfix to add at the end of the result

transform

A function to transform each element

Type Parameters

I

The type of elements in the input iterable

R

The type of elements in the result list


inline fun <I> Iterable<I>.joinTo(separatorFun: (I) -> I?, prefix: I? = null, postfix: I? = null): List<I>(source)

Joins elements of this iterable into a list with separators between elements. Separators are generated using separatorFun. Optional prefix and postfix can be added to the result. Null values from separator function are skipped.

Return

A list of elements with separators

Parameters

separatorFun

A function that generates a separator based on the current element

prefix

Optional prefix to add at the beginning of the result

postfix

Optional postfix to add at the end of the result

Type Parameters

I

The type of elements


inline fun <I> Iterable<I>.joinTo(separator: I? = null, prefix: I? = null, postfix: I? = null): List<I>(source)

Joins elements of this iterable into a list with a constant separator between elements. Optional prefix and postfix can be added to the result. Null separators are skipped.

Return

A list of elements with separators

Parameters

separator

The separator to insert between elements

prefix

Optional prefix to add at the beginning of the result

postfix

Optional postfix to add at the end of the result

Type Parameters

I

The type of elements


inline fun <I, R> Array<I>.joinTo(separatorFun: (I) -> R?, prefix: R? = null, postfix: R? = null, transform: (I) -> R?): Array<R>(source)

Joins elements of this array into an array with separators between elements. Each element is transformed using transform, and separators are generated using separatorFun. Optional prefix and postfix can be added to the result. Null values from transformations or separator function are skipped.

Return

An array of transformed elements with separators

Parameters

separatorFun

A function that generates a separator based on the current element

prefix

Optional prefix to add at the beginning of the result

postfix

Optional postfix to add at the end of the result

transform

A function to transform each element

Type Parameters

I

The type of elements in the input array

R

The type of elements in the result array


inline fun <I, R> Array<I>.joinTo(separator: R? = null, prefix: R? = null, postfix: R? = null, transform: (I) -> R?): Array<R>(source)

Joins elements of this array into an array with a constant separator between elements. Each element is transformed using transform. Optional prefix and postfix can be added to the result. Null values from transformations or separators are skipped.

Return

An array of transformed elements with separators

Parameters

separator

The separator to insert between elements

prefix

Optional prefix to add at the beginning of the result

postfix

Optional postfix to add at the end of the result

transform

A function to transform each element

Type Parameters

I

The type of elements in the input array

R

The type of elements in the result array