Question
Answer
The recommended way to generate UUID in Kotlin is to use `UUID.randomUUID()` method from `java.util.UUID` library. This is because Kotlin reuses everything from Java where it's applicable and only adds stuff on top of it where it's needed. It's also advised to follow Kotlin's philosophy and reuse idiomatic APIs instead of creating Utils classes. For example, a more idiomatic implementation would be `fun getUUID() = UUID.randomUUID().toString()`.
Alin B.
07/11/2018, 9:48 AMAndreas Sinz
07/11/2018, 9:49 AMUUID.randomUUID()
Alin B.
07/11/2018, 9:52 AMAndreas Sinz
07/11/2018, 9:54 AMgildor
07/11/2018, 9:57 AMAlin B.
07/11/2018, 9:59 AM`fun getUUID(): String {
return UUID.randomUUID().toString()
}`
gildor
07/11/2018, 10:00 AMAlin B.
07/11/2018, 10:00 AMgildor
07/11/2018, 10:00 AMgildor
07/11/2018, 10:01 AMgildor
07/11/2018, 10:01 AMkotlin.util.UUID
class?
The only difference practically would be just diffrent import, you now have jva.util.UUID
gildor
07/11/2018, 10:02 AMAlin B.
07/11/2018, 10:02 AMString.toUpperCase
Andreas Sinz
07/11/2018, 10:02 AMfun getUUID() = UUID.randomUUID().toString()
Can Orhan
07/11/2018, 10:10 AMgildor
07/11/2018, 10:11 AMAlin B.
07/11/2018, 10:34 AM