Scala Float until(end: Float, step: Float) method with example
Last Updated :
30 Jan, 2020
The until(end: Float, step: Float) method is utilized to return a range from the start value to exact previous value of specified end float value. Here the range’s values are jumping by step value.
Method Definition: defuntil(end: Float, step: Float): collection.immutable.Range
Return Type: It returns the range.
Example #1:
object GfG
{
def main(args : Array[String])
{
val result = ( 1.0 ).until( 12.0 , 3.0 )
println(result)
}
}
|
Output:
NumericRange(1.0, 4.0, 7.0, 10.0)
Example #2:
object GfG
{
def main(args : Array[String])
{
val result = ( 3.0 ).until( 20.0 , 2.0 )
println(result)
}
}
|
Output:
NumericRange(3.0, 5.0, 7.0, 9.0, 11.0, 13.0, 15.0, 17.0, 19.0)
Share your thoughts in the comments
Please Login to comment...