Kotlin Ranges
$count++; if($count == 1) { include "../mobilemenu.php"; } if ($count == 2) { include "../sharemediasubfolder.php"; } ?>
You can create a range in Kotlin via .. operator.
Syntax:
i..j
It will create a range i to j including both i and j.Let us see an example of range in Kotlin.
fun main(args: Array<String>)
{
for(i in 1..5)
{
print(i)
}
}
Output:
12345
Using downTo function we can go reverse in a range.
Example:
fun main(args: Array<String>)
{
for(i in 5 downTo 1)
{
print(i)
}
}
Output:
54321
Using step function we can increase the step count.
Example:
fun main(args: Array<String>)
{
for (i in 1..10 step 2)
{
print(i)
}
}
Above example prints odd numbers:
Output:
13579
What if we want to exclude the last value in a range?
For such scenarios, we can use until.
Example:
fun main(args: Array<String>)
{
for (i in 1 until 5)
{
print(i)
}
}
Output:
1234