Scala Set toSeq() method with example Last Updated : 18 Oct, 2019 Summarize Comments Improve Suggest changes Share Like Article Like Report The toSeq() method is utilized to return a seq consisting of all the elements of the set. Method Definition: def toSeq: Seq[A] Return Type: It returns a seq consisting of all the elements of the set. Example #1: Scala // Scala program of toSeq() // method // Creating object object GfG { // Main method def main(args:Array[String]) { // Creating a set val s1 = Set(1, 2, 3, 4, 5, 6) // Applying toSeq method val result = s1.toSeq // Display output for (ele <- result) println(ele) } } Output: 5 1 6 2 3 4 Example #2: Scala // Scala program of toSeq() // method // Creating object object GfG { // Main method def main(args:Array[String]) { // Creating a set val s1 = Set(41, 12, 23, 43, 1, 72) // Applying toSeq method val result = s1.toSeq // Display output for (ele <- result) println(ele) } } Output: 1 41 12 72 43 23 Comment More infoAdvertise with us Next Article Scala SortedSet toSeq() method with example R rupesh_rao Follow Improve Article Tags : Scala Scala Scala-Method scala-collection Scala-Set +1 More Similar Reads Scala Stack toSeq() method with example In Scala Stack class, the toSeq() method is utilized to return a seq consisting of all the elements of the stack. Method Definition: def toSeq: Seq[A] Return Type: It returns a seq consisting of all the elements of the stack. Example #1: Scala // Scala program of toSeq() // method // Import Stack im 2 min read Scala Set toList() method with example The toList() method is utilized to return a list consisting of all the elements of the set. Method Definition: def toList: List[A] Return Type: It returns a list consisting of all the elements of the set. Example #1: Scala // Scala program of toList() // method // Creating object object GfG { // Mai 1 min read Scala Set take() method with example The take() method is utilized to return a set consisting of first 'n' elements of the set. Method Definition: def take(n: Int): Set[A] Where 'n' is specifies the number of element to select. Return Type: It returns a set consisting of first 'n' elements of the set. Example #1: Scala // Scala program 1 min read Scala SortedSet toSeq() method with example The 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: Scala // Scala program of toSeq() // method import scala.collection.immutabl 1 min read Scala Set toString() method with example The toString() method is utilized to return a string consisting of all the elements of the set. Method Definition: def toString(): String Return Type: It returns a string consisting of all the elements of the set. Example #1: Scala // Scala program of toString() // method // Creating object object G 1 min read Scala Set toBuffer() method with example The toBuffer() method is utilized to return a buffer consisting of all the elements of the set. Method Definition: def toBuffer[B >: A]: Buffer[B] Return Type: It returns a buffer consisting of all the elements of the set. Example #1: Scala // Scala program of toBuffer() // method // Creating obj 1 min read Like