How do I add a tuple to a Swift Array?

后端 未结 8 506
夕颜
夕颜 2021-01-30 03:02

I\'m trying to add a tuple (e.g., 2-item tuple) to an array.

var myStringArray: (String,Int)[]? = nil
myStringArray += (\"One\", 1)

What I\'m g

8条回答
  •  太阳男子
    2021-01-30 03:35

    Note: It's not work anymore if you do:

    array += tuple 
    

    you will get error what you need is :

    array += [tuple]
    

    I think apple change to this representation because it's more logical

提交回复
热议问题