Open In App

Scala Float until(end: Float, step: Float) method with example

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

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:




// Scala program of Float until() 
// method 
    
// Creating object 
object GfG 
{  
    
    // Main method 
    def main(args:Array[String]) 
    
        
        // Applying until method 
        val result = (1.0).until(12.0, 3.0
            
            
        // Displays output 
        println(result) 
        
    


Output:

NumericRange(1.0, 4.0, 7.0, 10.0)

Example #2:




// Scala program of Float until() 
// method 
    
// Creating object 
object GfG 
{  
    
    // Main method 
    def main(args:Array[String]) 
    
        
        // Applying until method 
        val result = (3.0).until(20.0, 2.0
            
            
        // Displays output 
        println(result) 
        
    


Output:

NumericRange(3.0, 5.0, 7.0, 9.0, 11.0, 13.0, 15.0, 17.0, 19.0)


Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads