corda / net.corda.core / kotlin.collections.List

Extensions for kotlin.collections.List

indexOfOrThrow fun <T> List<T>.indexOfOrThrow(item: T): Int

Returns the index of the given item or throws IllegalArgumentException if not found.

randomOrNull fun <T> List<T>.randomOrNull(): T?

Returns a random element in the list, or null if empty

fun <T> List<T>.randomOrNull(predicate: (T) -> Boolean): T?

Returns a random element in the list matching the given predicate, or null if none found