I found that guard let behavior is different depending on where it is used - seems like a bug to me.
Playground code shown below.
var x:Int? = 10000
func foo(x: Int?) {
guard let x = x else {
// Value requirements not met, do something
return
}
//output: "10000\n"
print(x)
}
foo(x)
guard let x = x else {
throw NSError(domain: "d", code: 0, userInfo: nil)
}
//output: "Optional(10000)\n"
print(x)