Scala Listset apply() method with examples
Last Updated :
03 Nov, 2019
In Scala ListSet, apply() method is utilized to check if the given element is present or not in the listSet.
Method Definition: final def apply(elem: A): Boolean
Return Type: True if element is present else false.
Example 1:
import scala.collection.immutable. _
object GfG
{
def main(args : Array[String])
{
val m 1 = ListSet( 1 , 3 , 5 , 2 )
val res = m 1 .apply( 3 )
println(res)
}
}
|
Example 2:
import scala.collection.immutable. _
object GfG
{
def main(args : Array[String])
{
val m 1 = ListSet( 1 , 3 , 5 , 2 )
val res = m 1 .apply( 3 )
println(res)
}
}
|
Share your thoughts in the comments
Please Login to comment...