say i have a function
func function1() -> (result:Bool, data:String){
return(false, "false")
}
and i want to use the return value of the Bool in an if let statement so,
if let value = function1 {
//code
} else {
//code
}
How would I get this to work? I can't seem to see it in the swift docs, as it just aludes to it being a returned tuple, which you can access with dot notation, but only if you set the return to be a tuple first - so for example this would work
var value = function1()
if value.result {
////code
} else {
//code
}
works, but i'd like to fit it all into the actual if else if possible. Any ideas?
Aucun commentaire:
Enregistrer un commentaire