Kotlin Set random()
Syntax & Examples


Syntax of Set.random()

There are 2 variations for the syntax of Set.random() extension function. They are:

1.
fun <T> Collection<T>.random(): T

This extension function returns a random element from this collection.

2.
fun <T> Collection<T>.random(random: Random): T

This extension function returns a random element from this collection using the specified source of randomness.