Handling Index Out of Range Exception the Swift Way

Vadim Bulavin
1 min readDec 20, 2018

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/

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

Vadim Bulavin
Vadim Bulavin

Written by Vadim Bulavin

Senior iOS Software Engineer at Pluto TV. Creator of Yet Another Swift Blog https://www.vadimbulavin.com/. Coding for fun since 2008, for food since 2012.

No responses yet

Write a response