So, I do want my code to throw an exception if it can’t find the passed key, especially since I know it should be present, and I’m fine with it throwing an NPE, but I wonder if there’s a way to throw a meaningful
KeyNotFoundException
or something instead
val key = 1
val one = map[key] ?: throw KeyNotFoundException("Key of: $key not found" )