Related Articles

Related Articles

Scala Float to(end: Float, step: Float) method with example
  • Last Updated : 30 Jan, 2020

The to(end: FLoat, step: Float) method is utilized to return a range from the stated float value to the ‘end’, which is given in the arguments list and some step is also specified in the arguments list.

Method Definition: def to(end: Float, step: Float): Inclusive

Return Type: It returns the range.

Example #1:

filter_none

edit
close

play_arrow

link
brightness_4
code

// Scala program of Float to() 
// method 
// Creating object 
object GfG 
{  
    
    // Main method 
    def main(args:Array[String]) 
    
        // Applying to() method 
        val result = (0.0).to(9.0, 4.0
            
        // Displays output 
        println(result) 
            
    
}   

chevron_right


Output:

NumericRange(0.0, 4.0, 8.0)

Example #2:

filter_none

edit
close

play_arrow

link
brightness_4
code

// Scala program of Float to() 
// method 
// Creating object 
object GfG 
{  
    
    // Main method 
    def main(args:Array[String]) 
    
        // Applying to() method 
        val result = (5.0).to(30.0, 4.0
            
        // Displays output 
        println(result) 
            
    
}  

chevron_right


Output:

NumericRange(5.0, 9.0, 13.0, 17.0, 21.0, 25.0, 29.0)



My Personal Notes arrow_drop_up
Recommended Articles
Page :