Input
You can take values as input from the user using the readLine() function.
For example, we can ask the user to enter their age and store it in a variable:
==============================
readLine() returns the input as a string, even if the user enters a number.
So how do we take numbers as input?
We need to convert the input to the corresponding type. For example, to convert to Int we need to use toInt():
The code above takes two integers as input and outputs their sum.
Коментарі