Scala Mutable SortedSet toList() method
Last Updated :
26 Mar, 2020
In Scala mutable collections, toList() method is utilized to return a list consisting of all the elements of the SortedSet.
Method Definition: def toList: List[A]
Return Type: It returns a list 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( 10 , 20 , 30 , 40 , 50 )
val result = s 1 .toList
for (elem < - result)
println(elem)
}
}
|
Example #2:
import scala.collection.mutable.SortedSet
object GfG
{
def main(args : Array[String])
{
val s 1 = SortedSet( 41 , 12 , 23 , 43 , 1 , 72 )
val result = s 1 .toList
for (elem < - result)
println(elem)
}
}
|
Share your thoughts in the comments
Please Login to comment...