dimanche 5 septembre 2021

How can I prevent repeating numbers in a random range operator Kotlin?

I have an app in which gives you a certain photo based on an integer being fetched via

class RandomImageLogic(){
    fun retrive(): Int{
        return (1..9).random()
    }
}

However, it is not professional to have a repeated outcome, as I desire a random integer to be fetched each time I call the function in order for the image to be different each time my button is pressed. How can I fetch a new random integer whenever the button calls the function?




Aucun commentaire:

Enregistrer un commentaire