【发布时间】:2019-07-11 10:27:26
【问题描述】:
使用尾随闭包语法时,pass a function as a parameter of another function 似乎很容易。
但是我想在不使用尾随闭包语法的情况下这样做
func doSomethingTwo(closure: (String) -> Void) {
closure("AAA")
}
doSomethingTwo(closure: print("TEST") )
给予 无法将类型 '()' 的值转换为预期的参数类型 '(String) -> Void'
我知道
doSomethingTwo{ (test: String) in
print ("\(test)")
}
有效,但希望没有尾随闭包语法。
这不是家庭作业问题,我正在查看教程并进行了研究,但没有给我这个问题的答案。
【问题讨论】: