dimanche 14 mai 2023

Kotlin: Get x random unique elements from list using streams

I'm using the following stream() to get one random element from a list (of strings):

string.stream().filter { f -> f.contains("_reservert_") }.toList().random()

Is there a way to get x random AND uniqie elements in the same way?




Aucun commentaire:

Enregistrer un commentaire