What We’ve Learned

Optionals are tricky subject to get your head around, so it’s probably a good time to take a break and take stock of what we’ve learned so far.

This chapter has been all about working with the essential data types in Swift. We started with the numeric types—integers, floating-point numbers, and Booleans—and strings. We saw how to combine strings with the basic concatenation operator (+) and pattern substitution, and how to access their contents. Also, we went a little nuts with the Unicode support in Swift strings, but it’ll pay off if we ever want to support multiple languages, or lots of emoji.

We also played around with the different types of collections—arrays, sets, and dictionaries—and what each is particularly good for. Then we looked at Swift’s control flow operators, so we could use loops to go through the contents of collections.

Finally, since dictionaries may or may not give us a value for a given key, we started working with Swift optionals, to see how they represent the presence or absence of a value, and how to get to the value.

These are the building blocks we’ll use to build full-blown iOS apps. In the next chapter, you’ll see how to combine them into more sophisticated data structures, how to create functions to work with them, and how to do so with style and aplomb.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.133.146.237