2015年5月15日

Swift学习(三):闭包(Closures)

摘要: Swift学习(三):闭包(Closures) 定义 闭包(Closures)是独立的函数代码块,能在代码中传递及使用。 语法 {(parameters) -> return type in   statements } 注:闭包表达式语法可以使用常量参数、变量参数和 inout 类型作为参数,但皆不可提供默认值。 Trailing 闭包 注:Trailing 闭包是一个书写在函数括号之外(之后)的闭包表达式,函数支持将其作为最后一个参数调用。 funA("cosmokey"){ str in println("closureF : Hi , " + str) //closureF : Hi , cosmokey } 系统常见闭包:map、filter和reduce 阅读全文

posted @ 2015-05-15 09:38 CosmoKey 阅读(352) 评论(0) 推荐(0) 编辑

导航