/********************** Array definition **************************/
array : Array represents data
// Let decorated identifiers are immutable groups ( cannot be modified after element is determined )
The //var modifier identifier is a mutable array ( elements can be added and removed )
Note :
//1> definition array is used [], and does not need to add @
//2> Typically, an array is a generic collection , and all typically specifies which elements can be stored in the array
// immutable variable Group One : defines an array in which all strings are stored
Let names: Array<String> = ["Why", "LMJ", "Lnj", "YZ" ]
// immutable Arrays Two : defines an array in which all strings are stored
let names1: [String] = ["Why", "LMJ", "Lnj", "YZ"]
// immutable Arrays Two : defines an array in which all strings are stored
Let names2 = ["Why", "LMJ", "Lnj", "YZ"]
// No element can be added
Names.append ("22")
// array to hold multiple data types in the notation
Let array: [anyobject] = ["Why", 1.88]
// variable array
// Create variable array mode one :
var array1: [String] = Array()
// common variable array mode two :
var array2 = [String] ()
/********************** array Operation **************************/
adding elements : through the Append method
Array1. Append ("Why")
Array1. Append ("LNJ")
// Delete element
Let removestring = array1. Removeatindex (0)
Array1
// Modify Element
Array1[0] = "LMJ"
Array1
// get the values in the array
Let str = array1[0]
// Gets the number of elements in the array
Let count = array1. Count
/********************** Array Traversal **************************/
// traverse mode one :
for i in 0.. <names. Count {
Print (names[i])
}
traversal mode two : Forin
for item in names {
Print (item)
}
// traversal mode three : interval traversal
for item in names[0.. <2] {
Print (item)
}
/********************** Merging **************************/
//1. Merge of the same type
Let names5 = ["LMJ", "LNJ"]
Let names6 = ["YZ", "why"]
Let Names7 = names5 + names6
//2. Different types of merges : not additive
var array5 = ["Why", ]
Let array6 = [1.88, 60.5]
Let Array7 = Array5 + array6
for item in array6 {
array5. Append (item)
}
Array5
// Note : It is not recommended to store multiple elements in an array
Information about the 15.swift array