To create ranges of variables in Kotlin, you can use the rangeTo extension function or the .. operator of Kotlin. We can create a range of any Comparable type.
Let's look at the following example:
fun main(args: Array<String>) {
val int = args[0].toInt()
if (int in 0..10) {
println(int)
}
}
In this example, we retrieve a value from the args array.
The args array contains command-line arguments that can be used to pass parameters or specify a configuration when an application is launched.
To run a program with parameters in IntelliJ IDEA, click Run and choose Edit Configurations...:
![](https://static.packt-cdn.com/products/9781788996648/graphics/assets/03f76428-25dc-45be-a70a-1772556e6957.png)
In the window that opens, you can paste parameters in the Program arguments field:
![](https://static.packt-cdn.com/products/9781788996648/graphics/assets/3cb8a044-c2b6-4fbd-9363-294ba7f1f548.png)
Press OK and run the application. The output will be as follows:
2
Decompiled to Java, it looks like the following:
public static final void main(@NotNull String[] args) {
...