Scala Int until(end: Int) method with example
The until(end: Int) method is utilized to return a range from the start value to exact previous value of specified end integer value.
Method Definition: defuntil(end: Int): collection.immutable.Range
Return Type: It returns the range.
Example #1:
// Scala program of Int 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) } } |
chevron_right
filter_none
Output:
Range(1, 2, 3, 4, 5, 6, 7, 8)
Example #2:
// Scala program of Int until() // method // Creating object object GfG { // Main method def main(args : Array[String]) { // Applying until method val result = ( 10 ).until( 17 ) // Displays output println(result) } } |
chevron_right
filter_none
Output:
Range(10, 11, 12, 13, 14, 15, 16)