Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
In This Chapter |
After having introduced the notion of types in Chapter 9, we’re now ready to zoom into a type’s members one by one. In this chapter, we focus on methods. Classes and structs act as containers for both data and operations. As you’ll see, all the available members emphasize one of those aspects. For methods, we’re clearly in the latter camp because they consist of code bodies. Users of the type can invoke those methods to carry out certain tasks that can modify state.