How to copy end of the Array in swift?

后端 未结 6 1744
感动是毒
感动是毒 2020-11-30 15:20

There must be some really elegant way of copying end of the Array using Swift starting from some index, but I just could not find it, so I ended with this:

f         


        
6条回答
  •  囚心锁ツ
    2020-11-30 16:09

    You could use the new method removeFirst(_:) in Swift 4

    var array = [1, 2, 3, 4, 5]
    array.removeFirst(2)
    print(array) // [3, 4, 5]
    

提交回复
热议问题