rangeUntil

Common
JVM
JS
Native
1.9
operator fun <T : Comparable<T>> T.rangeUntil(
    that: T
): OpenEndRange<T>

(source)

Creates an open-ended range from this Comparable value to the specified that value.

This value needs to be smaller than that value, otherwise the returned range will be empty.

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

fun main(args: Array<String>) {
//sampleStart
val start = Date.valueOf("2017-01-01")
val end = Date.valueOf("2017-12-31")
val range = start..end
println(range) // 2017-01-01..2017-12-31

println("Date.valueOf(\"2017-05-27\") in range is ${Date.valueOf("2017-05-27") in range}") // true
println("Date.valueOf(\"2018-01-01\") in range is ${Date.valueOf("2018-01-01") in range}") // false
println("Date.valueOf(\"2018-01-01\") !in range is ${Date.valueOf("2018-01-01") !in range}") // true
//sampleEnd
}
Common
JVM
JS
Native
1.9
operator fun Double.rangeUntil(
    that: Double
): OpenEndRange<Double>

(source)

Creates an open-ended range from this Double value to the specified that value.

Numbers are compared with the ends of this range according to IEEE-754.

Common
JVM
JS
Native
1.9
operator fun Float.rangeUntil(
    that: Float
): OpenEndRange<Float>

(source)

Creates an open-ended range from this Float value to the specified that value.

Numbers are compared with the ends of this range according to IEEE-754.