uuid4
Construct new version 4 UUID.
Version 4 UUIDs are randomly generated from the best available random source. The selection of that source is depends on the platform. Some systems may be bad at generating sufficient entropy, e.g. virtual machines, and this might lead to collisions faster than desired. Version 5 may be used if this is the case and no other measures are possible to increase the entropy of the random source of the platform.
Return
New version 4 UUID of random data.
See also
Samples
import kotlin.test.Test
import kotlin.test.assertEquals
import kotlin.test.assertFails
import kotlin.test.assertFailsWith
import kotlin.test.assertNull
fun main() {
//sampleStart
val uuid = uuid4()
assertEquals(4, uuid.version)
assertEquals(2, uuid.variant)
//sampleEnd
}