We write asynchronous code when we know a task will take time to complete, whether because it's computationally expensive or we're making a network request. Testing this code can be difficult, especially when the asynchronous logic is internal. For example, let's say we're making a fire and forget request to load an image into an image view? We would likely make the request on a background queue and . . .
Key paths were introduced in Swift 4 and allow you to reference a type's properties without evaluating them. In this tutorial, we'll use key paths to write a generic array extension that makes sorting more convenient with code that is easier to read.
In this series we've done a lot of printing to the console. We've printed strings and constants and variables of other types. But it's often useful to be able to insert constants or variables directly into strings, especially when those constants or variables are values of other types. For example, when you want to say "Hello, [name]!" or "The bank account ending in [lastFourDigits] has a balance of [accountBalance]". In the bank account example . . .
A programmer's wife tells him to go to the store and get a loaf of bread. As he's leaving, she says "if they have eggs, get a dozen". The programmer comes back with 12 loaves of bread. A programmer's husband tells her to go to the store and says, "while you're there buy a dozen eggs". She never comes back. Programming is . . .
Functions are pieces of code that perform a specific task. A function can also be thought of as a set of instructions packaged together. In Part 1, you used the built-in Swift function `print` to output values to the console. So far you have used it to output "Hello, World!", "Hello, Xcode!", pi, and an email address. When you use a function . . .