Swift is an easy language to get started with. The syntax is easy to understand and reminiscent of other popular programming languages you may already be familiar with. In Swift Fundamentals, you learn the fundamentals of the Swift programming language.
In the previous episode of Swift Fundamentals, we briefly talked about variables and constants. You learned that the var keyword declares a variable and the let keyword declares a constant. Variables and constants both store values that can be referenced by a name.
In the previous episode, we explored some of the common types defined by the Swift standard library. Today, we continue that exploration by taking a close look at collection types. The Swift standard library defines three collection types, arrays, sets, and dictionaries. This episode zooms in on arrays and sets.
Another important collection type defined by the Swift standard library is the dictionary type. Dictionaries are better known as maps, hashes, or associative arrays in other programming languages. The idea is similar, though.
One of Swift's core features is safety and optionals tie neatly into that mindset. Developers new to Swift tend to struggle with optionals. Optionals are often seen as a hindrance instead of a powerful concept of the Swift language.
A common question developers have when they learn about optionals is "Why?" In this episode of Swift Fundamentals, we take a close look at optionals. Let's start with the obvious question "What is an optional?"
Optionals are an integral aspect of Swift development. They highlight a core concept of the Swift language. Safety.
At first glance, optionals look inconvenient and a necessary evil of Swift development. That's true if safety isn't high on your list of priorities. Unless you embrace optionals and what they represent, working with Swift will be a struggle and it will end in frustration.
Earlier in this series, we covered arrays, sets, and dictionaries. Collections are ideal for storing objects of the same type. Remember that Swift is very strict about type safety. That's why you're not allowed to store a string in an array of integers.
Control flow is an essential aspect of any programming language. In this and the next episode, we discuss loops and conditionals. We start with conditionals.