How to convert String to Int in Kotlin?
You could call toInt() on your String instances: fun main(args: Array<String>) { for (str in args) { try { val parsedInt = str.toInt() println(“The parsed int is $parsedInt”) } catch (nfe: NumberFormatException) { // not a valid int } } } Or toIntOrNull() as an alternative: for (str in args) { val parsedInt = str.toIntOrNull() … Read more