step

Returns a progression that goes over the same range with the given step.

Since Kotlin

1.0

Samples

import java.sql.Date
import kotlin.test.assertFalse
import kotlin.test.assertTrue

fun main() { 
   //sampleStart 
   val ascendingProgression = 1..6 step 2
val descendingProgression = 6 downTo 1 step 2
println(ascendingProgression.toList()) // [1, 3, 5]
println(descendingProgression.toList()) // [6, 4, 2] 
   //sampleEnd
}

Returns a progression that goes over the same range with the given step.

Since Kotlin

1.0

Samples

import java.sql.Date
import kotlin.test.assertFalse
import kotlin.test.assertTrue

fun main() { 
   //sampleStart 
   val ascendingProgression = 1L..6L step 2L
val descendingProgression = 6L downTo 1L step 2L
println(ascendingProgression.toList()) // [1, 3, 5]
println(descendingProgression.toList()) // [6, 4, 2] 
   //sampleEnd
}

Returns a progression that goes over the same range with the given step.

Since Kotlin

1.0

Samples

import java.sql.Date
import kotlin.test.assertFalse
import kotlin.test.assertTrue

fun main() { 
   //sampleStart 
   val ascendingProgression = 'a'..'f' step 2
val descendingProgression = 'f' downTo 'a' step 2
println(ascendingProgression.toList()) // [a, c, e]
println(descendingProgression.toList()) // [f, d, b] 
   //sampleEnd
}

Returns a progression that goes over the same range with the given step.

Since Kotlin

1.5

Samples

import java.sql.Date
import kotlin.test.assertFalse
import kotlin.test.assertTrue

fun main() { 
   //sampleStart 
   val ascendingProgression = 1u..6u step 2
val descendingProgression = 6u downTo 1u step 2
println(ascendingProgression.toList()) // [1, 3, 5]
println(descendingProgression.toList()) // [6, 4, 2] 
   //sampleEnd
}

Returns a progression that goes over the same range with the given step.

Since Kotlin

1.5

Samples

import java.sql.Date
import kotlin.test.assertFalse
import kotlin.test.assertTrue

fun main() { 
   //sampleStart 
   val ascendingProgression = 1UL..6UL step 2L
val descendingProgression = 6UL downTo 1UL step 2L
println(ascendingProgression.toList()) // [1, 3, 5]
println(descendingProgression.toList()) // [6, 4, 2] 
   //sampleEnd
}