-
Book Overview & Buying
-
Table Of Contents
Mastering Swift 6 - Seventh Edition
By :
In this chapter, we saw that adding support for subscripts to our custom types can greatly enhance their readability and usability. We saw that subscripts can be used to add an abstraction layer between our backend storage class and external code. Subscripts can also be used in a similar manner to computed properties, where the subscript is used to calculate a value.
We looked at examples of multidimensional arrays and how to use external names with subscripts, as well as how to extend types with subscripts. As we noted in the chapter, the key with subscripts is to use them appropriately and in a manner that is consistent with subscripts in the Swift language. It’s worth noting that we can also use optionals and generics with subscripts.
In the next chapter, we will look at how to use property observers and wrappers to manage state changes and enhance code reusability.
Unlock this book’s exclusive... |