kotcity4 / kotcity.util / kotlin.collections.List

Extensions for kotlin.collections.List

randomElement

fun <E> List<E>.randomElement(): E?

Extension function on any list that will return a random element from index 0 to the last index

randomElements

fun <E> List<E>.randomElements(numberOfElements: Int): List<E>

Extension function on any list that will return a list of unique random picks from the list. If the specified number of elements you want is larger than the number of elements in the list it returns the whole damn thing