Skip to content
Related Articles

Related Articles

Scala Int until(end: Int) method with example
  • Last Updated : 30 Jan, 2020

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:

filter_none

edit
close

play_arrow

link
brightness_4
code

// 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


Output:

Range(1, 2, 3, 4, 5, 6, 7, 8)

Example #2:

filter_none

edit
close

play_arrow

link
brightness_4
code

// 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


Output:

Range(10, 11, 12, 13, 14, 15, 16)



My Personal Notes arrow_drop_up
Recommended Articles
Page :