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:
object GfG
{
def main(args : Array[String])
{
val result = ( 0.0 ).to( 9.0 , 4.0 )
println(result)
}
}
|
Output:
NumericRange(0.0, 4.0, 8.0)
Example #2:
object GfG
{
def main(args : Array[String])
{
val result = ( 5.0 ).to( 30.0 , 4.0 )
println(result)
}
}
|
Output:
NumericRange(5.0, 9.0, 13.0, 17.0, 21.0, 25.0, 29.0)
Share your thoughts in the comments
Please Login to comment...