How to create an empty array in Swift?

2020-01-29 03:31发布

I'm really confused with the ways we create an array in Swift. Could you please tell me how many ways to create an empty array with some detail?

标签: ios arrays swift
13条回答
戒情不戒烟
2楼-- · 2020-01-29 04:07

you can remove the array content with passing the array index or you can remove all

    var array = [String]()
    print(array)
    array.append("MY NAME")
    print(array)
    array.removeFirst()
    print(array)
    array.append("MY NAME")
    array.removeLast()
    array.append("MY NAME1")
    array.append("MY NAME2")
    print(array)
    array.removeAll()
    print(array)
查看更多
登录 后发表回答