I am learning Kotlin from this YouTube video and at 35:45 he is running this code:
I've tried to run exactly the same code:
fun main() {
val x = readLine()?:"1"
val y = readLine()?:"1"
val z = x.toInt() + y.toInt()
print(z)
}
But I get this error:
Exception in thread "main" java.lang.NumberFormatException: For input string: ""
at java.base/java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
at java.base/java.lang.Integer.parseInt(Integer.java:662)
at java.base/java.lang.Integer.parseInt(Integer.java:770)
at MainKt.main(Main.kt:4)
at MainKt.main(Main.kt)
Can somebody help me please? I am really a noob in Kotlin (and software programming too) and I haven't found an answer on the web.
Thank you.