July 2018
Intermediate to advanced
400 pages
12h 14m
English
Ranges are a powerful tool in Kotlin, and with some practice you will find the syntax intuitive. For this simple challenge, open the Kotlin REPL (Tools → Kotlin → REPL) and explore some range syntax, including the toList(), downTo, and until functions. Enter the following ranges, one by one. Before pressing Command-Return (Ctrl-Return) to execute the line and see the result, think about what you expect the result to be.
Listing 3.13 Exploring ranges (REPL)
1 in 1..3 (1..3).toList() 1 in 3 downTo 1 1 in 1 until 3 3 in 1 until 3 2 in 1..3 2 !in 1..3 'x' in 'a'..'z'
Read now
Unlock full access