Swift array


  Translation results:

Swift is an open source programming language that supports multiple programming paradigms and compiled. It was released by Apple at WWDC (Apple Developer Conference) in 2014 and is used to develop iOS, OS X and watchOS applications.

Swift combines the best of C and Objective-C without the limitations of C compatibility.

Swift can use the same running environment as Objective-C on Mac OS and iOS platforms.

Swift arraysyntax

Swift arrays use ordered lists to store multiple values ​​of the same type. The same value can appear multiple times in different positions in an array.

Swift arrays will be forced to detect the type of elements. If the types are different, an error will be reported. Swift arrays should follow a form like Array<Element>, where Element is the only data type allowed to exist in this array.

If you create an array and assign it to a variable, the created collection can be modified. This means that after creating an array, you can change the items in the array by adding, deleting, or modifying. If you assign an array to a constant, the array cannot be changed, and neither the size nor the contents of the array can be modified.

Swift arrayexample

import Cocoa
var someInts = [Int](repeating: 10, count: 3)
var someVar = someInts[0]
print( "The value of the first element \(someVar)" )
print( "The value of the second element \(someInts[1])" )
print( "The value of the third element \(someInts[2])" )

Popular Recommendations

Home

Videos

Q&A