WHAT YOU WILL LEARN IN THIS CHAPTER:
Object-oriented programming (OOP) is one of the most important features in Swift programming—and structures and classes play an important role in supporting that. In Swift, structures and classes share many similarities, and many concepts that apply to classes apply to structure as well.
In this chapter, you will learn how to define structures and classes, and then use them. You will learn how to define the different types of properties in structures and classes, as well as define methods. By the end of this chapter, you will have a solid understanding of how structures and classes work in Swift.
A structure is a special kind of data type that groups a list of variables and places them under a unified name. The group of variables contained within a structure may have diverse data types. Structures are useful for storing related group of data. For example, consider a scenario in which you are implementing a game of Go. Figure 8-1 shows the board layout of Go. A typical game of Go has a grid of 19 × 19 lines, and players place markers, ...