In Scala mutable collections, SortedSet toSeq() method is utilized to return a seq consisting of all the elements of the SortedSet.
Method Definition: def toSeq: Seq[A]
Return Type: It returns a seq consisting of all the elements of the SortedSet.
Example #1:
import scala.collection.mutable.SortedSet
object GfG
{
def main(args : Array[String])
{
val s 1 = SortedSet( 11 , 12 , 13 , 14 )
val result = s 1 .toSeq
for (ele < - result)
println(ele)
}
}
|
Example #2:
import scala.collection.mutable.SortedSet
object GfG
{
def main(args : Array[String])
{
val s 1 = SortedSet( 4 , 2 , 3 , 43 , 11 , 72 )
val result = s 1 .toSeq
for (ele < - result)
println(ele)
}
}
|