Is there a function which returns to upper bound of a Scala range?

Create a simple range in Scala: val range = (1 to 10) Now I wanna find a function that returns the upper bound of this range like: val upper = range.max (upper: Int = 10) Or something to that effect, is there a neat way to do this?

>Solution :

You can browse the Scaladoc to find available methods. From what I understand end is what you’re looking for:

range.end

https://www.scala-lang.org/api/current/scala/collection/immutable/Range.html#end:Int

Leave a Reply