Let's imagine you have a Kotlin program with a number that is checked whether it is within a certain range or not. Your task is to fill the blanks in the code, define the range, and also insert the appropriate relational operator to make this checking operation work correctly. Remember, the range is an interval from start to end, and in Kotlin, it's usually created with the .. operator. Choose the correct operator and range to print out if the number is in the defined range or not.
Ranges
Checking if a number is within a certain range
Report a typo
Fill in the gaps with the relevant elements
fun main() {
val =
val number = 5
if (number range) {
println("$number is in the range")
} else {
println("$number is not in the range")
}
} ___
By continuing, you agree to the JetBrains Academy Terms of Service as well as Hyperskill Terms of Service and Privacy Policy.
Create a free account to access the full topic
By continuing, you agree to the JetBrains Academy Terms of Service as well as Hyperskill Terms of Service and Privacy Policy.