Scala Float to(end: Float, step: Float) method with example
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:
// 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) } } |
Output:
NumericRange(0.0, 4.0, 8.0)
Example #2:
// 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) } } |
Output:
NumericRange(5.0, 9.0, 13.0, 17.0, 21.0, 25.0, 29.0)
Contact Us