One. Arrays
1. Create an empty array
Way One:
var array1 = [Int] ()
Way two:
var array2 = array<string> ()
2. Create a hand with default values
var array3 = [Int].init (count:5 repeatedvalue:10)//5 elements, all 10
var array4 = Array<string>.init (count:5 repeatedvalue: "a")
3. Construct an array with literal literals
var array5:array<int> = [1,2,3,4,5]
4. Merging of two arrays
var = [Array6:array<int>]
var array7:array<int> = [4,5,6]
var array8 = Array6 + array7//Combined two array types need the same
5. Check if the array is empty
Print (Array8.isempty)
6. Number of elements
Print (Array8.count)
7. Add an Element (join later)
var array9:array<int> = [11,22,33]
Array9 + = [44,55,66]
Print (Array9)
8. Insert element (at specified position)
Array9.insert (atindex:0)//AT index 0, insert 10
9. Deleting an element
Array9.removeatindex (0)//delete an element with an index of 0
10. Get an Element
Print (array9[2])
11. Modifying an element (re-assignment)
ARRAY9[2] = 100
12. Modifying an element of an index interval
ARRAY9[3...5] = [1]//index 3,4,5 element full assignment is 1
ARRAY9[3...5] = [three-to-three]//index 3,4,5 elements are
13. Iterating through an array
For I in array9{
Print (i)//printing of each element
}
Swift--Array