1.

What Is Range In Scala? How To Create A Range In Scala?

Answer»

Range is a Lazy Collection in SCALA. Range is a class available in ‘scala’ package LIKE ‘scala.Range’. It is used to represent a sequence of integer values. It is an ordered sequence of integers.

Example:-

scala> 1 to 10

res0: scala.collection.immutable.Range.Inclusive = Range(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)

scala> 1 until 10

res1: scala.collection.immutable.Range = Range(1, 2, 3, 4, 5, 6, 7, 8, 9)

Range is a Lazy Collection in Scala. Range is a class available in ‘scala’ package like ‘scala.Range’. It is used to represent a sequence of integer values. It is an ordered sequence of integers.

Example:-

scala> 1 to 10

res0: scala.collection.immutable.Range.Inclusive = Range(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)

scala> 1 until 10

res1: scala.collection.immutable.Range = Range(1, 2, 3, 4, 5, 6, 7, 8, 9)



Discussion

No Comment Found