How to Code Custom Subscripts in Swift

If you are learning Swift and haven’t bumped into Coding Explorer, you owe it to yourself to stop by – there are several informative Swift code examples.

The most recent post covers custom subscripts in Swift. This is an interesting topic and the post does a good job covering the basics. Here’s a teaser on Subscripts in Swift:

Swift made it rather easy to implement subscripts in your own classes. Sure you can use an Array or Dictionary type if you wanted, and in many cases you should, but if writing it in subscript syntax is clearer and more expressive, that is a good reason to use it.