Download swift eBook


Array is an ordered, random-access collection type. Arrays are one of the most commonly used data types in an app. We use the Array type to hold elements of a single type, the array's Element type. An array can store any kind of elements---from integers to strings to classes.


  • Array<Element> // The type of an array with elements of type Element
  • [Element] // Syntactic sugar for the type of an array with elements of type Element
  • [element0, element1, element2, ... elementN] // An array literal
  • [Element]() // Creates a new empty array of type [Element]
  • Array(count:repeatedValue:) // Creates an array of count elements, each initialized to repeatedValue
  • Array(_:) // Creates an array from an arbitrary sequence


Arrays are an ordered collection of values. Values may repeat but must be of the same type.

Related Examples


555 Contributors: 19
Friday, July 28, 2017
Licensed under: CC-BY-SA

Not affiliated with Stack Overflow
Rip Tutorial:

Download eBook