vurmade.blogg.se

Range in kotlin
Range in kotlin







range in kotlin

Here is a basic example of it: val range = 1.rangeTo(9) We can also use rangeTo() function to create the range. Kotlin Range using the rangeTo() Operator: The only shortcoming is that we cannot create a range with a pattern where we skip/jump numbers, for example, if you want to create a range of number 1, 3, 5, 7, etc.

range in kotlin

If you want to create a range of numbers with all the numbers included in the range then using the. In the code example above, we created a range using the. Let us create a range from 1 to 9 using the. operator and the rangeTo() function, let's cover them one by one. Kotlin: Create a rangeĪs we mentioned above, we can either use the. We can create a range with the help of rangeTo() function in Kotlin or using the. The range may also have a step (step is used to jump numbers or characters while defining the range from start to end boundaries). The boundary points are start & end and both of them are included in the range.

range in kotlin

In the mathematical sense, a range is a sequence of numbers, characters, etc. In this tutorial, we will discuss about range in Kotlin.









Range in kotlin