swift闭包的另一种用法

这不是教程

当你碰到函数参数需要传递一个闭包(closure)时,一般是可以直接这么传递的(假定无返回):

// 教程一般教你在参数位置传递closure:
someMethod(arg1, arg2, arg3: {
    args -> Void in
    //codes here 
})

// swift同时有一种“同步”的写法:
someMethod(arg1, arg2){
  args -> Void in
  //codes here
}

  

posted @ 2014-07-02 11:04  $walker  阅读(317)  评论(0编辑  收藏  举报