Error[8]: Undefined offset: 2, File: /www/wwwroot/outofmemory.cn/tmp/plugin_ss_superseo_model_superseo.php, Line: 121
File: /www/wwwroot/outofmemory.cn/tmp/plugin_ss_superseo_model_superseo.php, Line: 473, decode(

概述参见英文答案 > removing duplicate elements from an array                                    34个 >             Swift 3 Generics: How to Find The Common Set of Two Generic Arrays                               参见英文答案 > removing duplicate elements from an array34个
> Swift 3 Generics: How to Find The Common Set of Two Generic Arrays2个
我有一个公式重新调整数组作为例子var Array = [a,s,d,f,g,h,e].我想要的是运行一个for循环或一些其他选项,它给我一个,e – 只有唯一值.我怎么能用ios Swift做到这一点? 如果您不关心订单:

只需使用一套:

let set: Set = ["a","s","d","f","g","h","e"]print(set) // ["a","e","h"]

如果您关心订单:

使用此扩展,允许您删除AnySequence的重复元素,同时保留顺序:

extension Sequence where Iterator.Element: Hashable {    func unique() -> [Iterator.Element] {        var alreadyAdded = Set<Iterator.Element>()        return self.filter { alreadyAdded.insert([+++]).inserted }    }}let array = ["a","e"]let result = array.unique()print(result) // ["a","e"]
总结

以上是内存溢出为你收集整理的数组 – 如何使用Swift显示数组的唯一元素?全部内容,希望文章能够帮你解决数组 – 如何使用Swift显示数组的唯一元素?所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

)
File: /www/wwwroot/outofmemory.cn/tmp/route_read.php, Line: 126, InsideLink()
File: /www/wwwroot/outofmemory.cn/tmp/index.inc.php, Line: 166, include(/www/wwwroot/outofmemory.cn/tmp/route_read.php)
File: /www/wwwroot/outofmemory.cn/index.php, Line: 30, include(/www/wwwroot/outofmemory.cn/tmp/index.inc.php)
数组 – 如何使用Swift显示数组的唯一元素?_app_内存溢出

数组 – 如何使用Swift显示数组的唯一元素?

数组 – 如何使用Swift显示数组的唯一元素?,第1张

概述参见英文答案 > removing duplicate elements from an array                                    34个 >             Swift 3 Generics: How to Find The Common Set of Two Generic Arrays                               参见英文答案 > removing duplicate elements from an array34个
> Swift 3 Generics: How to Find The Common Set of Two Generic Arrays2个
我有一个公式重新调整数组作为例子var Array = [a,s,d,f,g,h,e].我想要的是运行一个for循环或一些其他选项,它给我一个,e – 只有唯一值.我怎么能用ios Swift做到这一点? 如果您不关心订单:

只需使用一套:

let set: Set = ["a","s","d","f","g","h","e"]print(set) // ["a","e","h"]

如果您关心订单:

使用此扩展,允许您删除AnySequence的重复元素,同时保留顺序:

extension Sequence where Iterator.Element: Hashable {    func unique() -> [Iterator.Element] {        var alreadyAdded = Set<Iterator.Element>()        return self.filter { alreadyAdded.insert().inserted }    }}let array = ["a","e"]let result = array.unique()print(result) // ["a","e"]
总结

以上是内存溢出为你收集整理的数组 – 如何使用Swift显示数组的唯一元素?全部内容,希望文章能够帮你解决数组 – 如何使用Swift显示数组的唯一元素?所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1047185.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-25
下一篇 2022-05-25

发表评论

登录后才能评论

评论列表(0条)

保存