๐break
๐ง ๆฝๅทฅไธญ
Swift โฉ flow control โฉ control transfer โฉ break
โ error: unlabeled 'break' is only allowed inside a loop or switch, a labeled break is required to exit an if or do. ( ๐ see: for...in vs. forEach )
replit๏ผfor...in vs. forEach
(1...10).forEach { n in
if n > 2 { break } // โญ `break` is inside a "closure"
// ^^^^^
// โ error:
// โข unlabeled 'break' is only allowed inside a loop or switch
// โข labeled 'break' is required to exit an `if` or `do`
}labeled 'break'
unlabeled 'break'
Last updated
Was this helpful?