I've come across interesting behavior of Kotlin in Android Studio. When I try to log an element of an array dynamically where the index supplied is -1 and the array is empty, the program freezes in the emulator but never throws an error.
Example code:
val myObjects = mutableListOf<MyObject>()
val objIndex = -1
...
Log.d(TAG, "Non-existent element: ${myObjects[objIndex].myValue}") //stuck here, doesn't move past
What causes this seemingly infinite loop or pause in the Kotlin code execution?