itnext.io itnext.io

Unhandled Exceptions in Kotlin Collections

Why didn’t you warn me earlier?Kotlin’s collections package in the Kotlin Standard Library is full of wonderful goodies.Unfortunately, some of these methods can throw exceptions. This is extremely undesirable if your program doesn’t already handle these exceptions, causing your program to crash at runtime. Yucks.I have personally encountered exceptions like java.lang.IndexOutOfBoundsException or java.util.NoSuchElementException...