Scala SortedSet apply() method with example
Last Updated :
03 Nov, 2019
The apply() method is utilized to test if some elements are exist in the SortedSet.
Method Definition: def apply(elem: A)
Return Type: It returns true if some elements are present in the SortedSet else it returns false.
Example #1:
import scala.collection.immutable.SortedSet
object GfG
{
def main(args : Array[String])
{
val s 1 = SortedSet( 1 , 2 , 3 , 4 , 5 )
val result = s 1 .apply( 3 )
println(result)
}
}
|
Example #2:
import scala.collection.immutable.SortedSet
object GfG
{
def main(args : Array[String])
{
val s 1 = SortedSet( 1 , 2 , 3 , 4 , 5 )
val result = s 1 .apply( 10 )
println(result)
}
}
|
Share your thoughts in the comments
Please Login to comment...