Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
函数可以返回swift中使用的另一个函数_Swift - Fatal编程技术网

函数可以返回swift中使用的另一个函数

函数可以返回swift中使用的另一个函数,swift,Swift,函数是一级类型。这意味着一个函数可以返回另一个函数作为其值 当我实现此功能时,出现以下错误: 命令 /Applications/Xcode6-Beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift 失败,退出代码254 此外,如果此功能在实时解决方案中有用,请参见下面代码中的函数声明,请参见Int周围的括号。它指示输入参数 func makeIncrementer() -> (Int) -&

函数是一级类型。这意味着一个函数可以返回另一个函数作为其值

当我实现此功能时,出现以下错误:

命令 /Applications/Xcode6-Beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift 失败,退出代码254

此外,如果此功能在实时解决方案中有用,请参见下面代码中的函数声明,请参见
Int
周围的括号。它指示输入参数

func makeIncrementer() -> (Int) -> Int
                          ^^^^^^^^^^^^

这种功能性可以使基于运行时值的动态代码变得更容易。

您的代码看起来不错。它对我有用,没有任何修改。错误是很重要的else@Anil使用M.M.答案后,我能够解决问题。
func makeIncrementer() -> (Int) -> Int
                          ^^^^^^^^^^^^