gpt4 book ai didi

ios - Swift 1.2 中的 Variadic @autoclosure?

转载 作者:搜寻专家 更新时间:2023-10-31 08:18:53 24 4
gpt4 key购买 nike

既然 @autoclosure 是参数声明的一部分而不是类型,那么如何声明函数采用可变数量的自动闭包?

之前:

public func coalesce<T>(all : @autoclosure () -> T? ...) -> T? {
for f : () -> T? in all {
if let x = f() { return x }
}
return nil
}

之后:???

最佳答案

我打开了 rdar://19782845,“Swift 1.2:Variadic auto-closures no longer supported”,Apple Developer Relations 给出了以下回复:

This issue behaves as intended based on the following:

@autoclosure is only allowed on parameters of function type, and varargs is an array. This is not expected to work.

关于ios - Swift 1.2 中的 Variadic @autoclosure?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29750244/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com