doorxp

Blog

Swift Set 按下标访问

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

As of Xcode7 beta6/Swift2.0:

let mySet: Set = ["a", "b", "c", "d"]
mySet[mySet.startIndex.advancedBy(2)] // -> something from the set.
let mySet: Set = ["a", "b", "c", "d"]
mySet[mySet.index(mySet.startIndex, offsetBy: 2)] // -> will print "d" as it advances by 2

发表评论:

«   2025年5月   »
1234
567891011
12131415161718
19202122232425
262728293031
控制面板
您好,欢迎到访网站!
  查看权限
网站分类
搜索
最新留言

    Powered By Z-BlogPHP 1.5.1 Zero

    Copyright doorxp.com Rights Reserved.