Returning Tuples
So far, we’ve taken a thorough tour of what Swift offers for object-oriented development. In a lot of languages, that would be enough. But in Swift, it’s only half the story.
Swift is great for object-oriented programming, but it also allows for more of a functional programming style. In functional programming, there’s an emphasis on passing data around, instead of maintaining state in classes and mutating it all the time.
One significant trait of functional programming is that it’s better to pass values to and from functions, rather than references. If we have an object of some class, and two parts of our code can modify its data at the same time, it can lead to confusing bugs. In functions, we generally want to pass the data ...
Get iOS 9 SDK Development now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.