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