为什么这在 Swift 中是可能的?
How come this is possible in Swift?
这是
UIView.animateWithDuration(1, animations: {
newView.transform = afterAnimationTransform
})
还有这个
UIView.animateWithDuration(1){
newView.transform = afterAnimationTransform
}
等效?如果是,这个功能叫什么?它只对最后一个参数有效吗?
它被称为尾随闭包,是的,这些表达式是等价的,第二个是shorthand。阅读 Swift 2.1 编程语言。
这是
UIView.animateWithDuration(1, animations: {
newView.transform = afterAnimationTransform
})
还有这个
UIView.animateWithDuration(1){
newView.transform = afterAnimationTransform
}
等效?如果是,这个功能叫什么?它只对最后一个参数有效吗?
它被称为尾随闭包,是的,这些表达式是等价的,第二个是shorthand。阅读 Swift 2.1 编程语言。