Scala ListSet exists() method with example
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:
import scala.collection.immutable. _
object GfG
{
def main(args : Array[String])
{
val m 1 = ListSet( 1 , 2 , 3 , 4 , 5 , 7 )
val result = m 1 .exists( _== 9 )
println(result)
}
}
|
Example 2:
import scala.collection.immutable. _
object GfG
{
def main(args : Array[String])
{
val m 1 = ListSet( 1 , 2 , 3 , 4 , 5 , 7 )
val result = m 1 .exists( _> 9 )
println(result)
}
}
|
Last Updated :
03 Nov, 2019
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...