A generic method that can return a random integer between 2 parameters like ruby does with rand(0..n).
rand(0..n)
Any suggestion?
If the numbers you want to choose from are not consecutive, you can use random().
Usage:
val list = listOf(3, 1, 4, 5) val number = list.random()
Returns one of the numbers which are in the list.