In Swift functions, why 'return' must be outside for loop, when function includes a for loop with if statement inside the loop?

后端 未结 0 394
攒了一身酷
攒了一身酷 2020-12-05 16:16

Assume a returning function:

func check(scores: [Int]) -> Bool {
    for score in scores {
        if score < 80 {
            return false
        }
           


        
相关标签:
回答
  • 消灭零回复
提交回复
热议问题