Scala Set drop() method with example Last Updated : 15 Oct, 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): Set[A]] Return Type: It returns all elements except first 'n' elements. Example #1: Scala // Scala program of drop() // method // Creating object object GfG { // Main method def main(args:Array[String]) { // Creating sets val s1 = Set(5, 1, 2, 3, 4) // Applying drop method val s2 = s1.drop(2) // Displays output for(elem <- s2) println(elem) } } Output: 2 3 4 Example #2: Scala // Scala program of drop() // method // Creating object object GfG { // Main method def main(args:Array[String]) { // Creating sets val s1 = Set(5, 1, 2, 3, 4) // Applying drop method val s2 = s1.drop(4) // Displays output for(elem <- s2) println(elem) } } Output: 4 Comment More infoAdvertise with us Next Article Scala Set drop() method with example R rupesh_rao Follow Improve Article Tags : Scala Scala Scala-Method scala-collection Scala-Set +1 More Similar Reads Scala Stack drop() method with example In Scala Stack class, the drop() method is utilized to drop the first ânâ elements from the top of the stack. Method Definition: def drop(n: Int): Stack[A] Return Type: It returns a new stack with all the elements except the first ânâ ones from the top of the given stack. Example #1: Scala // Scala 2 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 Scala Set dropRight() method with example The dropRight() is utilized to return all elements except last 'n' elements. Method Definition: def dropRight(n: Int): Set[A] Return Type: It returns a set containing all elements except last 'n' elements. Example #1: Scala // Scala program of dropRight() // method // Creating object object GfG { // 1 min read Scala Set dropWhile() method with example The dropWhile() method is utilized to drop the longest prefix of elements from the set that satisfies the stated condition. Method Definition: def dropWhile(p: (A) => Boolean): Set[A] Return Type: It returns a set containing all the elements after dropping the longest prefix of elements from the 1 min read Scala SortedSet 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): SortedSet[A]] Return Type: It returns all elements except first 'n' elements. Example #1: Scala // Scala program of drop() // method import scala.c 1 min read Like