mapToArray

inline fun <L : List<E>, E, R> L.mapToArray(transform: (E) -> R): Array<R>

Perform the given transform on every element in this list, and return a new array with the results.

Equivalent to this.map { transform(it) }.toTypedArray(), but saves on the creation of an intermediate list.

this method is no-alloc, like other methods in this family such as fastEach.


inline fun <T, R> Array<T>.mapToArray(transform: (T) -> R): Array<R>

Perform the given transform on every element in this array, and return a new array with the results.

Equivalent to this.map { transform(it) }.toTypedArray(), but saves on the creation of an intermediate list.


inline fun <T, R> Collection<T>.mapToArray(transform: (T) -> R): Array<R>

Perform the given transform on every element in this list, and return a new array with the results.

Equivalent to this.map { transform(it) }.toTypedArray(), but saves on the creation of an intermediate list.


inline fun <K, V, R> Map<K, V>.mapToArray(transform: (Map.Entry<K, V>) -> R): Array<R>

Perform the given transform on every element in this map, and return a new array with the results.

Equivalent to this.map { transform(it) }.toTypedArray(), but saves on the creation of an intermediate list.