Simplified version of my code is like this:
var joined = false
for room in rooms {
checkRoom() { // async func
if room.player.count == 1 {
join(room)
joined = true
// break doesnt work here
}
}
if joined {
break;
}
}
I need to exit this loop because it is still checking other rooms after joining one. I want to stop checking rest of rooms when joined becomes true. But ofcourse it becomes true in async call only so my method does not work.
How can I exit this loop when joined becomes true?
forloop, simply check the next room in theelsestatement in your closure