toList

fun <T> Array<out T>.toList(): List<T>
fun ByteArray.toList(): List<Byte>
fun ShortArray.toList(): List<Short>
fun IntArray.toList(): List<Int>
fun LongArray.toList(): List<Long>
fun FloatArray.toList(): List<Float>
fun DoubleArray.toList(): List<Double>
fun BooleanArray.toList(): List<Boolean>
fun CharArray.toList(): List<Char>
fun <T> Iterable<T>.toList(): List<T>

Returns a List containing all elements.


fun <K, V> Map<out K, V>.toList(): List<Pair<K, V>>

Returns a List containing all key-value pairs.

inline fun <T> Enumeration<T>.toList(): List<T>

Returns a list containing the elements returned by this enumeration in the order they are returned by the enumeration.

Samples

import samples.*
import kotlin.test.*
fun main() { 
   //sampleStart 
   val numbers = java.util.Hashtable<String, Int>()
numbers.put("one", 1)
numbers.put("two", 2)
numbers.put("three", 3)

// when you have an Enumeration from some old code
val enumeration: java.util.Enumeration<Int> = numbers.elements()

// you can convert it to list and transform further with list operations
val list = enumeration.toList().sorted()
assertPrints(list, "[1, 2, 3]") 
   //sampleEnd
}