๐return
Swift โฉ flow control โฉ control transfer โฉ return
cannot use return in the body of a for...in loop, except that the loop is inside a function.
replit ( ๐ see: for...in vs. forEach )
โ error: return invalid outside of a func.
for n in 1...10 {
if n == 3 { return } // โ error
// ^^^^^^
// โ error: return invalid outside of a func
}
Last updated
Was this helpful?