I am new in Swift and have a small question.
I want to build a function which can return values of different types based on the conditions. What return type should I use?? Below is the function. I use "??" as the placeholder. Can anybody help to change the "??" with correct return type?? Thanks!!
fun Req_amt() -> ?? {
if let input_amt = readLine() {
if let amount = Float(input_amt) {
return amount
} else {
return "Bad number."
}
} else {
return "Bad input."
}
}
Aucun commentaire:
Enregistrer un commentaire