Challenge: Trying Out Some Ranges

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 (ToolsKotlinREPL) 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'