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 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) } } |
chevron_right
filter_none
Output:
2 3 4
Example #2:
// 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) } } |
chevron_right
filter_none
Output:
4
Recommended Posts:
- Scala Iterator drop() method with example
- Scala List drop() method with example
- Scala Map drop() method with example
- Scala Queue drop() method with example
- Scala SortedSet drop() method with example
- Scala Stack drop() method with example
- Scala TreeSet drop() method with example
- Scala SortedMap drop() method with example
- Scala Mutable SortedMap drop() method with example
- Scala BitSet drop() method with example
- Scala mutable SortedSet drop() method
- Scala immutable TreeSet drop() method
- Scala Set &() method with example
- Scala Set dropRight() method with example
- Scala Set equals() method with example
- Scala Set dropWhile() method with example
- Scala Set diff() method with example
- Scala Set copyToArray() method with example
- Scala Set subsetOf() method with example
- 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.

