1.Swift
A.continue break都作用于当层循环
B.break是跳出当层循环
C.continue是跳过当层循环的某次循环,继续下次循环
D.return直接返回,后面的语句不再执行
F.循环控制语句中跳出指定某层循环:findAnswer为任意字符串
func sample() -> () {
//findAnswer可以指定跳出某层循环
findAnswer: for i in 0...10 {
print("i:\(i)")
for j in 0...10 {
if j == 5 {
break findAnswer
}
print("j:\(j)")
}
}
}
网友评论