Book Image

Mastering Swift

By : Jon Hoffman
Book Image

Mastering Swift

By: Jon Hoffman

Overview of this book

Table of Contents (22 chapters)
Mastering Swift
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Summary


Adding support for subscripts to our custom types can greatly enhance its readability and usability. As we saw in this chapter, 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 as computed properties where the subscript is used to calculate a value. The key with subscripts is to use them appropriately and in a manner that is consistent with other subscripts in the Swift language.