Swift array map() method: Tutorial & examples
Overview In Swift programming, the array map() method is used for transforming an array by applying the same operation to each element of the array using a specified…
Swift: 3 ways to calculate the average of a numeric array
This practical, example-based article walks you through a couple of different approaches to calculating the average (the mean) of all elements in a numeric array (an array that…
Swift: 5 ways to find the sum of a numeric array
This practical, code-centric article will walk you through several different ways to calculate the sum of a numeric array (an array that only contains numerical elements) in Swift….
Swift: Find the index of a specific element in an array
Overview Swift provides several built-in array methods that can help you find the index of an element (when knowing its value or some of its characteristics) in a…
Swift: 3 ways to reverse an array
When developing applications with Swift, there might be cases where you need to reverse a given array, such as when you want to display an array of messages…
Swift: 2 ways to get the type of a variable at runtime
This succinct, practical article will walk you through a couple of different approaches to determining the data type of a variable at runtime in Swift. Without any further…
3 Ways to Concatenate Arrays in Swift
In the context of programming, concatenating arrays means joining two or more arrays into one array. This succinct example-based article will walk you through a couple of different…
Working with the insert() method in Swift
Overview In Swift, the insert() method has 2 variants: insert(_:at:) and insert(contentOf:at:). insert(_:at:) insert(_:at:) is used to insert a single element at the specified position in a given…
Swift: How to append elements to an array
Using the append(_:) method Appending elements to an array means adding new elements at the end of the array. You can do that in Swift by using the…
Swift: How to find the length of a given array
This short and straightforward article shows you a couple of different ways to find the length of a given array in Swift. The easiest approach is to use…