// *** before: ***
UIView.animate(withDuration: 0.3, animations: {
view.alpha = 0
}, completion: { _ in
view.removeFromSuperview()
})
// only the last closure could leave the parentheses, so as soon as there
// were two, both went back inside and the punctuation piled up
// *** in version 5.3: ***
UIView.animate(withDuration: 0.3) {
view.alpha = 0
} completion: { _ in
view.removeFromSuperview()
}
// the first closure keeps no label, the rest are named
func fetch(from url: String,
onSuccess: (String) -> Void,
onFailure: (Error) -> Void) { }
fetch(from: "https://example.com") { text in
print(text)
} onFailure: { error in
print(error)
}