From Swift programming language :
If the catch clause does not specify a pattern, the clause will match and associate any error with a local constant named error .
That is, there is an implicit let error in the catch expression:
do { // … } catch { print("caught: \(error)") }
Alternatively, it seems that let constant_name also a valid pattern, so you can use it to rename the error constant (this can be convenient if the name error already in use):
do { // … } catch let myError { print("caught: \(myError)") }
Arkku Jul 11 '15 at 1:44 2015-07-11 01:44
source share