A generic method that can return a random integer between 2 parameters like ruby does with rand(0..n).
Any suggestion?
As of 1.3, the standard library provided multi-platform support for randoms, see this answer.
If you are working with Kotlin JavaScript and don't have access to java.util.Random, the following will work:
fun IntRange.random() = (Math.random() * ((endInclusive + 1) - start) + start).toInt()
Used like this:
// will return an `Int` between 0 and 10 (incl.)
(0..10).random()