Reputation: 11655
in java I can handle a loop and stop the loop with a condition in 1 line statement.
boolean continue=true;
for (int i=0;i<100 && continue;i++){ // <------ 1 line
Is this also possible in swift and when how ?
Upvotes: 0
Views: 73
Reputation: 25459
Yes you can do the same but in swift continue is a key word so replace it with something different:
var cont = true
for var i = 0; i < 100 && cont; i++ {
println("Value: \(i)")
if i == 20 {
cont = false
}
}
Upvotes: 2