swift 3.0 之@Never | @escaping

  • @escaping

Swift3,闭包参数默认为non-escaping,也可以使用@escaping属性关键字为标识闭包可 "逃逸".

Escaping and Nonescaping Closures in Swift 3

  • @Never

    Swift3.0删除了@noreturn 关键字,替代方案:


/// The type of expressions that can never happen.
public /closed/ enum Never { /no values/ }
func foo() -> Never {
fatalError("no way out!")
}

It’s Now or Never…

参考

1 < https://swiftunboxed.com/lang/closures-escaping-noescape-swift3/?>

2.http://ericasadun.com/2016/09/06/its-now-or-never/?utm_campaign=This%2BWeek%2Bin%2BSwift&utm_medium=email&utm_source=This_Week_in_Swift_101

你可能感兴趣的:(swift 3.0 之@Never | @escaping)