step

Common
JVM
JS
Native
1.0
infix fun IntProgression.step(step: Int): IntProgression
(source)

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

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

fun main(args: Array<String>) {
//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
}
Common
JVM
JS
Native
1.0
infix fun LongProgression.step(step: Long): LongProgression
(source)

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

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

fun main(args: Array<String>) {
//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
}
Common
JVM
JS
Native
1.0
infix fun CharProgression.step(step: Int): CharProgression
(source)

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

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

fun main(args: Array<String>) {
//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
}
Common
JVM
JS
Native
1.5
infix fun UIntProgression.step(step: Int): UIntProgression
(source)

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

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

fun main(args: Array<String>) {
//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
}
Common
JVM
JS
Native
1.5
infix fun ULongProgression.step(step: Long): ULongProgression
(source)

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

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

fun main(args: Array<String>) {
//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
}