Array

In this short Swift code example, you will learn how to: Initialize an Array with 5 elements in Swift, Remove an element from an array at the specified index. Create an Array Let’s first create a new array with some elements in it. // Initialize Array with 5 elements var myArray = [1,2,3,4,5] // Print…

Read More Remove Element From an Array at Specified Index in Swift

Lets’ create an Array with three elements first. var myArray = [“Swift”, “Objective-C”, “PHP”] Now we can loop through all elements in Array for arrayElement in myArray { print(arrayElement) } Loop through an array of elements and print out element index as well as element value. for (index, element) in myArray.enumerated() { print(“Element index: \(index).…

Read More Loop Through Array Elements in Swift

In this tutorial, you will learn how to create both a one-dimensional and multidimensional arrays in Swift. After reading this tutorial, you might also be interested in learning how to use FlatMap and Map when working with arrays. How to Use flatMap in Swift. Code Examples, How to Use map(_:) in Swift. Code Examples, Ways…

Read More Multidimensional Array Example in Swift