Home IOS Development Getting dynamic worth in iOS Swift

Getting dynamic worth in iOS Swift

0
Getting dynamic worth in iOS Swift

[ad_1]

I’m new to iOS Native, I’ve an expertise of Flutter and in flutter we have now a key phrase dynamic and we will return dynamic worth from perform. I would like this too in Swift however when i’m making an attempt to attain this i get this error

Sort of expression is ambiguous with out a sort annotation

This is my dummy code:

func returnValue(_ flag: Bool) -> Any {
    if flag {
        return "A string"
    } else {
        return 42 // An integer
    }
}

let end result = returnValue(true)

Are you able to inform me how am i able to do that in Swift

[ad_2]

LEAVE A REPLY

Please enter your comment!
Please enter your name here