Scala Map toSeq() method with example
The toSeq() method is utilized to display a sequence from the Scala map.
Method Definition: def toSeq: Seq[A]
Return Type: It returns a sequence from the stated map.
Example #1:
// Scala program of toSeq() // method // Creating object object GfG { // Main method def main(args:Array[String]) { // Creating a map val m1 = Map(3 -> "geeks", 4 -> "for", 4 -> "for") // Applying toSeq method val result = m1.toSeq // Displays output println(result) } } |
chevron_right
filter_none
Output:
ArrayBuffer((3, geeks), (4, for))
Example #2:
// Scala program of toSeq() // method // Creating object object GfG { // Main method def main(args:Array[String]) { // Creating a map val m1 = Map(3 -> "geeks", 4 -> "for", 2 -> "cs") // Applying toSeq method val result = m1.toSeq // Displays output println(result) } } |
chevron_right
filter_none
Output:
ArrayBuffer((3, geeks), (4, for), (2, cs))
Recommended Posts:
- Scala Set toSeq() method with example
- Scala TreeSet toSeq() method with example
- Scala Queue toSeq() method with example
- Scala SortedSet toSeq() method with example
- Scala Iterator toSeq() method with example
- Scala Stack toSeq() method with example
- Scala SortedMap toSeq() method with example
- Scala Int !=(x: Int) method with example
- Scala Map get() method with example
- Scala Int ==(x: Int) method with example
- Scala Set last() method with example
- Scala Map min() method with example
- Scala Map max() method with example
- Scala | map() method
- Scala Set ++() method with example
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


