In Scala mutable collections, SortedSet find() method is utilized to find the first element of the SortedSet that satisfies the given predicate if present.
Method Definition: def find(p: (A) => Boolean): Option[A]
Return Type: It returns the first element of the SortedSet which satisfies the given predicate.
Example #1:
import scala.collection.mutable.SortedSet
object GfG
{
def main(args : Array[String])
{
val s 1 = SortedSet( 115 , 112 , 3 , 113 )
val result = s 1 .find( _ == 3 )
println(result)
}
}
|
Example #2:
import scala.collection.mutable.SortedSet
object GfG
{
def main(args : Array[String])
{
val s 1 = SortedSet( 25 , 22 , 33 , 13 )
val result = s 1 .find( _ == 10 )
println(result)
}
}
|
Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape,
GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out -
check it out now!