在Set中的索引处获取对象

在Set中的索引处获取对象,第1张

在Set中的索引获取对象 Swift 3及更高版本

您可以

offsetBy:
.startIndex

let mySet: Set = ["a", "b", "c", "d"]mySet[mySet.index(mySet.startIndex, offsetBy: 2)] // -> something from the set.
Swift 2(已淘汰

您可以

advancedBy()
.startIndex

let mySet: Set = ["a", "b", "c", "d"]mySet[mySet.startIndex.advancedBy(2)] // -> something from the set.
Swift 1.x(已淘汰)

与相似

String
,您必须
advance()
.startIndex

let mySet: Set = ["a", "b", "c", "d"]mySet[advance(mySet.startIndex, 2)] // -> something from the set.


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

原文地址: http://outofmemory.cn/zaji/5642251.html

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

发表评论

登录后才能评论

评论列表(0条)

保存