The until() method is utilized to return a range starting from first point to end point. Here the first point is inclusive but the endpoint is exclusive.
Method Definition: (First_Point).until(End_Point)
Return Type: It returns the created range.
Example #1:
// Scala program of Float until() // method // Creating object object GfG
{ // Main method
def main(args : Array[String])
{
// Applying until method
val result = ( 1 ).until( 9 )
// Displays output
println(result)
}
} |
Output:
Range(1, 2, 3, 4, 5, 6, 7, 8)
Example #2:
// Scala program of Float until() // method // Creating object object GfG
{ // Main method
def main(args : Array[String])
{
// Applying until method
val result = (- 6 ).until( 0 )
// Displays output
println(result)
}
} |
Output:
Range(-6, -5, -4, -3, -2, -1)