Arrays are ordered collections that store multiple values of the same type in Swift. This playground is a short, hands-on learning example that demonstrates how to create arrays, inspect them, and transform them using Swift's built-in properties and methods. Every line is runnable inside an Xcode playground so you can see the results immediately.
- Creating arrays with literals and an empty typed array (
[Int]()). - Reading the element count with
.count. - Adding elements with
.append(_:)and removing them with.remove(at:). - Locating elements with
.firstIndex(of:)and checking membership with.contains(_:). - Sorting with
.sorted()and populating an array inside aforloop over a range.
git clone https://github.com/ahmetbostanciklioglu/Array.git
cd Array
unzip Array.playground.zip
open Array.playgroundOpen Array.playground in Xcode and run each line to view the results in the playground sidebar.
- Xcode 12 or later
- Swift 5+
- iOS playground target
Ahmet Bostancıklıoğlu — @ahmetbostanciklioglu · ahmetbostancikli@gmail.com
⭐ If this helped you, consider giving the repo a star!