I have an array of fruits. I am fetching a fruit randomly (see following codes). Questions: How do I remove this fruit from the array after fetching it?
let fruits = ["apple", "orange", "banana", "pineapple", "lemon" ]
func getRandomFruit() -> String {
let randomFruit = fruits.randomElement()!
return randomFruit
}
Aucun commentaire:
Enregistrer un commentaire