Kotlin Animal goes into an infinite loop on EOF
Animal.kt goes into an infinite loop, on end-of-file.
readLine returns null when end-of-file is reached, so looping back to try readline again will not work, it will not prompt again after an end-of-file.
Best to throw an exception on interactive readLine sessions returning null:
return readLine()?.uppercase() ?: throw EndOfInputException()
can we notify the person who authored that PR?
@patimen Can you have a look at this?
Ah, OK. I think I'll switch to readln(), which will throw an exception instead of return null. I use it in the other Kotlin code for that reason, I must have missed this one.
https://github.com/coding-horror/basic-computer-games/pull/432
Thanks @pcholt for the bug report and thanks @patimen for the fix!