Skip to main content

Posts

Showing posts with the label import

Renaming types on Import

The following snippet of code illustrates how the rename functionality works in Kotlin after importing a type. import kotlin.random.Random as KRandom import java.util.Random as JRandom fun useDifferentRandomClasses(): String {     return "Kotlin random: " +             KRandom.nextInt( 2 ) +             " Java random:" +             JRandom().nextInt( 2 ) +             "." } In the above snippet of code, we see that we are importing two Random types. We are able to use KRandom for the type imported from Kotlin and JRandom for the type imported from java.util.Random