Handling Index Out of Range Exception the Swift Way
Swift is a statically typed language which allows to catch lots of syntactic errors early, such as wrong parameter type or name.
Another kind of errors are logical 🎓. They rarely can be detected automatically and are usually the trickiest among all. The well-known “Index out of range” exception in a prominent example of such.
In current article we’ll see how to prevent “Out of bounds” exceptions in Swift by overloading Collection subscript.
đź“ť The full article is posted on my website: http://www.vadimbulavin.com/handling-out-of-bounds-exception/