如何在swift中

时间:2015-07-27 15:42:52

标签: swift ios8 closures

我想声明一个类型为closure的局部变量,我该怎么办?

1 个答案:

答案 0 :(得分:1)

var myClosure: (myParamaterTypes) -> myReturnTypes

例如:

var myClosure: (Int, Int) -> Int  // type is (Int, Int) -> Int
myClosure = {(integer01: Int, integer02: Int) -> Int in return integer01 + integer02}