In Scala ListSet, exists() method is utilized to check if the given predicate satisfies the elements of the listSet or not.
Method Definition: def exists(p: (A) => Boolean): Boolean
Return Type: It returns true if the stated predicate holds true for some elements of the listset else it returns false.
Example 1:
// Scala program of exists() // method import scala.collection.immutable._// Creating object object GfG { // Main method def main(args:Array[String]) { // Creating Listset val m1 = ListSet(1, 2, 3, 4, 5, 7) // Applying exists method val result = m1.exists(_==9) // Displays output println(result) } } |
chevron_right
filter_none
Output:
false
Example 2:
// Scala program of exists() // method import scala.collection.immutable._// Creating object object GfG { // Main method def main(args:Array[String]) { // Creating listset val m1 = ListSet(1, 2, 3, 4, 5, 7) // Applying exists method val result = m1.exists(_>9) // Displays output println(result) } } |
chevron_right
filter_none
Output:
false
Recommended Posts:
- Scala ListSet takeWhile() method with example
- Scala ListSet sum() method with example
- Scala ListSet size() method with example
- Scala ListSet min() method with example
- Scala ListSet product() method with example
- Scala ListSet max() method with example
- Scala ListSet find() method with example
- Scala ListSet filter() method with example
- Scala ListSet filterNot() method with example
- Scala ListSet count() method with Example
- Scala ListSet isEmpty() method with Example
- Scala Listset apply() method with examples
- ListSet in Scala
- Scala Iterator exists() method with example
- Scala Map exists() method with example
- Scala List exists() method with example
- Scala Set exists() method with example
- Scala Queue exists() method with example
- Scala SortedSet exists() method with example
- Scala SortedMap exists() 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.

