I am using android studio and kotlin. I have a map collection with keys and values. I would like to randomly shuffle the key-value pairs and save one in a variable. I would then like to access the value of the randomly selected key-value and shuffle the value which is a String of letters. Lastly I would like to display both the key (which is a Sting) and the value (with the shuffled letters).
fun main() { lateinit var currentWord: String
val allWordsList = mutableMapOf<String, String>(
"pao" to "bread",
"porta" to "door",
"carro" to "car"
)
currentWord = allWordsList.random()
}
Aucun commentaire:
Enregistrer un commentaire