+ 2
Your code won't compile, if you have not declared x before using it (in print statement). Also, type of Exception must be specified in catch. catch (e: Exception)
4th Dec 2022, 7:45 PM
Tibor Santa
Tibor Santa - avatar
+ 1
Did you read both parts of my comment? If you do not declare the variable X, the code won't even compile, you cannot run it at all. You declare a variable with val or var keyword. And if the type is not nullable, you also need to initialize it.
4th Dec 2022, 9:46 PM
Tibor Santa
Tibor Santa - avatar