Open In App

Scala Int until(end: Int) method with example

Last Updated : 30 Jan, 2020
Improve
Improve
Like Article
Like
Save
Share
Report

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) 
        
    


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) 
        
    


Output:

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


Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads