Added a Kotlin variation.

This commit is contained in:
Rhinemann 2023-05-07 23:15:50 +03:00
parent 64c9e43742
commit a8cbadbe7d
1 changed files with 2 additions and 2 deletions

View File

@ -1,10 +1,10 @@
fun protectedInput(variableName: String): Int { fun protectedInput(variableName: String): Int {
do { do {
try { try {
print("Enter $variableName: "); print("Enter $variableName: ")
return readln().toInt() return readln().toInt()
} catch (e: Exception) { } catch (e: Exception) {
println("${variableName.uppercase()} must be an integer!"); println("${variableName.uppercase()} must be an integer!")
} }
} while (true) } while (true)
} }