我有一个没有任何参数的displayForPhone和displayForPrinter函数。我想从另一个称为“display”的函数返回这些函数。我在斯威夫特游乐场下面的代码,但它只是说,有一个错误,但从来不告诉我什么错误是:在没有参数的Swift中返回函数类型
func displayForPrinter() {
println("Displaying for printer")
}
func displayForPhone() {
println("Displaying for phone")
}
func display:(shouldDisplayForPhone :Bool) -> (void) -> (void) {
return shouldDisplayForPhone ? displayForPhone : displayForPrinter
}
去除多余的':'和void应该是void – Ian