Why does the reverse() function in the Swift standard library return ReverseRandomAccessCollection?

前端 未结 3 482
野趣味
野趣味 2020-12-03 07:46

Now that I\'ve learned Swift (to a reasonable level) I\'m trying to get to grips with the standard library, but in truth it\'s mainly ελληνικά to me!

So a specific q

3条回答
  •  [愿得一人]
    2020-12-03 08:08

    With Swift 3.0, you can directly access the Array value through index.

    var streets = ["Albemarle", "Brandywine", "Chesapeake"]
    streets = streets.reversed()
    print("Array at index is \(streets[0])")
    

    This will print "Chesapeake"

提交回复
热议问题