func test1() {
if true {
let x = 1
print(x)
} else {
let x = 2
print(x)
}
}
func test2(arg1: Int?, arg2: (Int, String)?) {
if let x = arg1 {
print(x)
} else if let (x, y) = arg2 {
print(x, y)
}
}
func test3(arg: Int?) {
switch arg {
case let .some(x) where x == 0:
print(x)
case let .some(x) where x == 1,
let .some(x) where x == 2:
print(x)
fallthrough
case let .some(x) where x == 3:
print(x)
default:
break
}
}
struct Err1 : Error { }
func test4(arg: () throws -> Void) {
do {
try arg()
} catch let x as Err1 {
print(x)
} catch let x {
print(x)
}
}
func test5(_ x: Int) {
let x = x
print(x)
}
func testCaptureVariable() {
let capturedVariable = 0
_ = { [capturedVariable] in
print(capturedVariable)
}
}