Scala SortedSet drop() method with example Last Updated : 03 Nov, 2019 Comments Improve Suggest changes Like Article Like Report The drop() method is utilized to delete the first ānā elements or to return all elements except first 'n' elements. Method Definition: def drop(n: Int): SortedSet[A]] Return Type: It returns all elements except first 'n' elements. Example #1: Scala // Scala program of drop() // method import scala.collection.immutable.SortedSet // Creating object object GfG { // Main method def main(args:Array[String]) { // Creating SortedSets val s1 = SortedSet(5, 1, 2, 3, 4) // Applying drop method val s2 = s1.drop(2) // Displays output for(elem <- s2) println(elem) } } Output: 3 4 5 Example #2: Scala // Scala program of drop() // method import scala.collection.immutable.SortedSet // Creating object object GfG { // Main method def main(args:Array[String]) { // Creating SortedSets val s1 = SortedSet(5, 1, 2, 3, 4) // Applying drop method val s2 = s1.drop(4) // Displays output for(elem <- s2) println(elem) } } Output: 5 Comment More infoAdvertise with us Next Article Scala SortedSet drop() method with example G gopaldave Follow Improve Article Tags : Scala Scala-Method scala-collection Similar Reads Scala SortedSet dropRight() method with example The dropRight() is utilized to return all elements except last 'n' elements. Method Definition: def dropRight(n: Int): SortedSet[A] Return Type: It returns a SortedSet containing all elements except last 'n' elements. Example #1: Scala // Scala program of dropRight() // method import scala.collectio 1 min read Scala SortedSet dropWhile() method with example The dropWhile() method is utilized to drop the longest prefix of elements from the SortedSet that satisfies the stated condition. Method Definition: def dropWhile(p: (A) => Boolean): SortedSet[A] Return Type: It returns a TreeSet containing all the elements after dropping the longest prefix of el 1 min read Scala SortedSet -() method with example The -() method is utilized to creates a new SortedSet with a given element removed from the SortedSet. Method Definition: def -(elem: A): SortedSet[A] Return Type: It returns a new SortedSet with a given element removed from the SortedSet. Example #1: Scala // Scala program of -() // method import s 1 min read Scala Set drop() method with example The drop() method is utilized to delete the first ânâ elements or to return all elements except first 'n' elements. Method Definition: def drop(n: Int): Set[A]] Return Type: It returns all elements except first 'n' elements. Example #1: Scala // Scala program of drop() // method // Creating object o 1 min read Scala TreeSet drop() method with example In Scala TreeSet class, the drop() method is utilized to drop the first ânâ elements of the TreeSet. Method Definition: def drop(n: Int): TreeSet[A] Return Type: It returns a new TreeSet with all the elements except the first ânâ ones. Example #1: Scala // Scala program of drop() // method // Import 2 min read Like