gpt4 book ai didi

swift : What does "_, _ " means?

转载 作者:搜寻专家 更新时间:2023-11-01 05:50:28 25 4
gpt4 key购买 nike

我在对 Alamofire 进行一些研究时发现了这段代码:

    switch encodingResult {

case .Success(let upload, _, _):

upload.responseJSON { response in

if let info = response.result.value as? Dictionary<String, AnyObject> {

if let links = info["links"] as? Dictionary<String, AnyObject> {

if let imgLink = links["image_link"] as? String {

print("LINK: \(imgLink)")
}
}
}

} case .Failure(let error):
print(error)
}

我可以知道 _, _ 是什么意思吗?

我见过像 let _ = "xyz" 这样的用法,但我以前从未见过它像上面的代码那样使用。

这是否意味着它有2个参数没有被使用?

提前致谢

最佳答案

是的,这基本上意味着它们是未使用的值,在 Apples documentation 中有描述.

Wildcard Pattern

A wildcard pattern matches and ignores any value and consists of an underscore (_). Use a wildcard pattern when you don’t care about the values being matched against. For example, the following code iterates through the closed range 1...3, ignoring the current value of the range on each iteration of the loop:

for _ in 1...3 {
// Do something three times.
}

关于 swift : What does "_, _ " means?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36513031/

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