val result = 'c' in 'a'..'f' println(result)
The range 'a'..'f' includes all characters from 'a' to 'f'. Since 'c' is within this range, the expression returns true.
val x = 10 val isInRange = x in 1..10 println(isInRange)
The number 10 is included in the range 1..10, so x in 1..10 evaluates to true.
val num = 5 val range = 10 downTo 1 println(num in range)
The downTo operator creates a decreasing range from 10 to 1. Since 5 is between 10 and 1, num in range is true.
val range = 1..10 step 3 println(7 in range)
The range 1..10 step 3 includes 1, 4, 7, and 10. However, the in operator checks for containment based on the step sequence. Since 7 is included in the stepped range, the output should be true. But in Kotlin, the in operator with stepped ranges checks for exact matches in the progression. Actually, 7 is included, so the output is true.
val x = 3.5 val range = 1.0..5.0 println(x in range)
The range operator (..) in Kotlin does not support floating point types like Double. This code will not compile because 1.0..5.0 is invalid.