Labeled statement in Swift
var firstMatchValue = -1
let array1 = [1, 2, 3]
let array2 = [2, 3, 4]
firstLoop: for value1 in array1 {
for value2 in array2 {
if value1 == value2 {
firstMatchValue = value2
break firstLoop
}
}
}
//firstMatchValue is 2
- Log in to post comments