In Scala mutable collections, SortedSet -() method is utilized to creates a new SortedSet with a given element removed from the SortedSet.
Method Definition: def -(elem: A): SortedSet[A]
Return Type: It returns a new SortedSet with a given element removed from the SortedSet.
Example #1:
import scala.collection.mutable.SortedSet
object GfG
{
def main(args : Array[String])
{
val s 1 = SortedSet( 11 , 55 , 33 , 20 , 100 )
val result = s 1 -( 100 )
print(result)
}
}
|
Output:
TreeSet(11, 20, 33, 55)
Example #2:
import scala.collection.mutable.SortedSet
object GfG
{
def main(args : Array[String])
{
val s 1 = SortedSet( 43 , 23 , 12 , 41 , 1 )
val result = s 1 -( 1 )
print(result)
}
}
|
Output:
TreeSet(12, 23, 41, 43)