VOOZH about

URL: https://www.geeksforgeeks.org/scala/scala-set-filter-method-with-example/

⇱ Scala Set filter() method with example - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Scala Set filter() method with example

Last Updated : 18 Oct, 2019
The filter() method is utilized to select all elements of the set which satisfies a stated predicate.
Method Definition: def filter(p: (A) => Boolean): Set[A] Return Type: It returns a set containing all the elements of the set which satisfies the given predicate.
Example #1:
Output:
Set(5, 3)
Example #2:
Output:
Set()
Comment

Explore