欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

Arrays

程序员文章站 2024-03-05 23:09:31
...
// Arrays
var dogNames = ["Miki", "Miki1", "Miki2"]
dogNames.first    // Miki
dogNames.last     // Miki2
dogNames.count    // 3
dogNames[1]     // Miki1
dogNames.append("Miki3")    // "Miki", "Miki1", "Miki2", "Miki3"
dogNames.insert("Miki4", at: 3)    // "Miki", "Miki1", "Miki2", "Miki4", "Miki3"
dogNames.removeAll() // empty

var emptyDoubles: [Double] = []    // create an empty array by specifying the Element type

reference: https://developer.apple.com/documentation/swift/array