![]() ![]() To use this in a Kotlin project you need to add: import java.util.* In Java there are far too many date classes in use at the moment, so for simplicity we will use the original Date class, despite most of its methods being deprecated rather than LocalDate, which is its successor. As an example let's create a range that works for dates. ![]() It isn't difficult to create your own ranges and progressions. Roughly speaking, Range allows you to write things like: for(i in 1.10)Īnd a Progression is a range for which you can specify a step size, for example: for(i in 1.10 step 2)Īs already explained in connection with the for loop, ranges and progressions integrate into the for using the rangeTo function as an operator. Kotlin provides two data types that make it easier to write for loops – the Range and the Progression.
0 Comments
Leave a Reply. |