Mastering macOS Programming
上QQ阅读APP看书,第一时间看更新

Structs, classes, and other data structures

Ways of defining and handling structured data are an important part of any programming language that supports object-oriented programming. Swift has extended the patterns typical of Objective C, Java, and the like, to include structures that are passed by value, called structs, and those that are passed by reference, called classes (see Value and reference types in this chapter). There is also the much lighter-weight tuple, which offers a kind of bridge between data structures and collection types such as dictionaries.

As well as the fact that structs are value types and classes are reference types, there are a few other points of departure, but the two structures have a lot more similarities than they do differences.