xcode 'array' 不可用:请从您的惰性序列构造一个数组:Array(...)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/32242876/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
'array' is unavailable: please construct an Array from your lazy sequence: Array(...)
提问by Mitsuaki Ishimoto
I updated Xcode to 9 beta, I have fixed my code to swift 2.
我将 Xcode 更新为 9 beta,我已将代码修复为 swift 2。
Now, I have an error "'array' is unavailable: please construct an Array from your lazy sequence: Array(...)" on the following code.
现在,我在以下代码中遇到错误“'array' 不可用:请根据您的惰性序列构造一个数组:Array(...)”。
var dic: [String: String] = Dictionary<String, String>(minimumCapacity: 8)
dic.values.array// error
How should I write instead of this code?
我应该如何编写而不是这段代码?
Array(dic.values)
This code is correct?
这段代码正确吗?
I could not find the Apple's document about LazyMapCollection. Thank you.
我找不到关于 LazyMapCollection 的 Apple 文档。谢谢你。
回答by Aderstedt
Like this:
像这样:
var dic: [String: String] = Dictionary<String, String>(minimumCapacity: 8)
let values: [String] = [String](dic.values)