Tsallaka zuwa abun ciki
Justice Tech School

Kotlin Ranges

Ranges use .. and until. step changes the increment and downTo counts down. in checks membership.

Example
for (i in 1..3) print("$i ")
println()
for (i in 0 until 10 step 3) print("$i ")
println()
for (i in 3 downTo 1) print("$i ")
println()
println(5 in 1..10)

Exercise

Count down.

for (i in 3  1)

Quiz Test

Does 1..3 include 3?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.