Swift array set value of index not working

后端 未结 1 435
遇见更好的自我
遇见更好的自我 2021-01-28 10:33

I have a method (contents below) where queue2 is just an [Int]. I printed a lot of things to see if everything was working up to a point.

public func cool(item:         


        
相关标签:
1条回答
  • 2021-01-28 10:41

    If queue2 is empty, this line is illegal no matter what back is:

    queue2[back] = item
    

    You cannot refer to an index that doesn't exist, and an empty array has no indexes (indices).

    0 讨论(0)
提交回复
热议问题