7. Creating Your Own Syntax: Subscripts and Advanced Operators
Swift is such a powerful language that it allows you to create your own new full-fledged language. You will hear people talk about writing functional Swift and writing jQuery-like Swift. It is great to have such flexibility. With Swift you can take an existing syntax and apply it to other things. For example, subscripts allow you to provide functionality to the square-brackets notation. What you do with that square-brackets notation is up to you. You can provide subscripts for enumerations, structures, and classes. You can use subscripts to query a class to get some sort of information back.
You probably know subscripts from arrays and dictionaries. You use subscripts to access members ...
Get Learning Swift 2 Programming, Second Edition 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.