How to get a random item from a list in an easy and concise way.
ex: if I want to get an even random number from this list that.
val list = listOf(1, 2, 3, 4, 5, 6, 7, 9).filter { it % 2 != 0 }
Note:
I know there are some similar answers in java that solves this problem but I think we can have a more concise way in kotlin.
Aucun commentaire:
Enregistrer un commentaire