I am trying to create a variable that gets a random word from an array. I am using the method below to find it however it give me an error "Missing return function expected to return 'String"
let array: [String] = ["Example1", "Example2"]
var chooseOne: String {
[Int(arc4random_uniform(UInt32(self.array.count)))]
}
How do I get the function to work? I am brand new to swift, and any help would be appreciated. Thanks in advance!
Aucun commentaire:
Enregistrer un commentaire