0

What is the problem in this code?

fun main(args: Array<String>) { var age = readLine()!!toInt() when { age<0 -> println("Invalid Age") age<=11 -> println("Child") age<=17 -> println("Teen") age<=64 -> println("Adult") else -> println("Senior") } }

27th May 2022, 9:19 AM
atharv bhati
2 Answers
+ 3
You forgot a period in the between the not-null assertion characters and the toInt method. It should be readLine()!!.toInt()
27th May 2022, 9:35 AM
Justice
Justice - avatar
+ 2
Thnx for your help
27th May 2022, 9:38 AM
atharv bhati