Add samples for range construction operators

This commit is contained in:
kenji tomita
2017-12-26 07:37:04 +09:00
committed by Ilya Gorbunov
parent 31d650a041
commit 4cb2b12f01
2 changed files with 46 additions and 0 deletions
@@ -105,6 +105,7 @@ private class ClosedFloatRange (
* Creates a 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.
* @sample samples.ranges.Ranges.rangeFromComparable
*/
public operator fun <T: Comparable<T>> T.rangeTo(that: T): ClosedRange<T> = ComparableRange(this, that)
@@ -112,6 +113,7 @@ public operator fun <T: Comparable<T>> T.rangeTo(that: T): ClosedRange<T> = Comp
* Creates a range from this [Double] value to the specified [that] value.
*
* Numbers are compared with the ends of this range according to IEEE-754.
* @sample samples.ranges.Ranges.rangeFromDouble
*/
@SinceKotlin("1.1")
public operator fun Double.rangeTo(that: Double): ClosedFloatingPointRange<Double> = ClosedDoubleRange(this, that)
@@ -120,6 +122,7 @@ public operator fun Double.rangeTo(that: Double): ClosedFloatingPointRange<Doubl
* Creates a range from this [Float] value to the specified [that] value.
*
* Numbers are compared with the ends of this range according to IEEE-754.
* @sample samples.ranges.Ranges.rangeFromFloat
*/
@JvmVersion
@SinceKotlin("1.1")