Chapter 9. Custom Subscripting

Custom subscripts were added to Objective-C in 2012. At that time, Chris Lattner was already 2 years into developing Swift and like other good features of Objective-C, subscripts became a part of the Swift language. I did not frequently use custom subscripts in Objective-C, but I did know that they were a part of the language when I needed them. Subscripts in Swift seem, to me, to be a more natural part of the language, possibly because they were part of the language when it was released and not added in later.

In this chapter, you will learn the following topics:

  • What are custom subscripts
  • How to add custom subscripts to classes, structures, or enums
  • How to create read/write and read-only subscripts
  • How to use external ...

Get Mastering Swift 2 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.