taylor swift taylor swift - 1 year ago 77
Swift Question

How to determine if Swift loop was interrupted

In python we can use

for a in A:

and have the
statement execute if the loop finished normally. Is there a similar construct in Swift?

Answer Source

Such a feature was discussed on the Swift Evolution mailing list and – as far as I can see – rejected. See

which also shows a possible workaround:

outer: do {
    for i in 0..<10 {
        if i == 5 { break outer }
    print("no break occurred")
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download