func noEscape(doSomeThing: @noescape() -> ()) {
// domeSomething closure MUST be called in the body of this function
// or in a function immediately called from here
doSomeThing()
}
noEscape {
print("hello")
}
func labelsLoop(foo: Array<Int>, bar: Array<Int>) -> Int {
var result = 0
fooLoop: for fu in foo {
barLoop: for ba in bar {
if ba > fu {
result = ba
// works for continue also
break fooLoop
}
}
}
return result
}
labelsLoop(foo: [1, 2, 9], bar: [4, 5, 6]) // result: 4
https://realm.io/news/tryswift-hector-matos-hipster-swift/