Chapter 3
Swift with Style

In the previous chapter, we explored the basics of Swift: the type system, control flow, optionals, and so on. And, assuming Swift isn’t your first programming language, you’ve probably guessed the next step is combining these simple pieces together into more complex, more capable, and more interesting constructs. While that is what we’re going to do, it’s not as straightforward as you might think.

Swift is a remarkably flexible language, one that takes its inspiration from a number of different sources. It’s true to both the object-oriented nature of Objective-C and to new ideas about design, elegance, and maintainability in functional programming languages. You can write Swift like Objective-C, like C, like Java, or even like Haskell, and it will still work.

Since there’s no one right way to write Swift, we will be making choices about how we want to organize our code. In this chapter, we’re going to look at what Swift offers us for building bigger data structures, and how our choices will affect the evolution of our apps as we write and rewrite them. If the one hammer in your toolbox when you started this book was the good ol’ class, let’s discover what we can do by taking lightweight types like structures and enumerations and extending them with custom functionality.

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

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