I want to assign value to a variable inside the if expression.
func message() -> Int?{
var y = ""
if x.Sender(msg, reply: { message in
replyFunc {
if message.command == .success {
y = "Hello World"
print(y) //It prints hello world
}
}
}) {
print("Error")
}
return y //Here I don't get Hello World
}
I want to assign 'y' from inside the expression.
Edit: This issue is of asynchronous callback and please refer to Matt's comment for the tutorial.