Join our book community on Discord
In the previous chapter, you learned how to group instruction sequences together using functions and closures.
It's time to think about how to represent complex objects in your code. For example, think about a car. You could use a String
constant to store a car name and a Double
variable to store a car price, but they are not associated with one another. You've seen that you can group instructions together to make functions and closures. In this chapter, you'll learn how to group constants and variables together in a single entity using classes and structures, and how to manipulate them. You'll also learn how to use enumerations to group a set of related values together.
By the end of this chapter, you'll have learned how to create and initialize a class, create a subclass from an existing class, create and initialize a structure, differentiate...