The map.remove() function in Scala removes a specific element, a key-value pair, from the map.
None is returned.The illustration below shows a visual representation of the map.remove() function.
The following module is required in order to use this function:
scala.collection.mutable.Map
map.remove(key)
mapis the name of the queue.
The map.remove() function requires a key to remove that specific key-value pair from the map.
The map.remove() function removes a specific element, a key-value pair, from a map.
The following code shows how to use the map.remove() function in Scala.
import scala.collection.mutable.Mapobject Main extends App {//creating mapval map = scala.collection.mutable.Map(1 -> "Tom",2 -> "Alsvin",3 -> "Eddie")//map containg key value pairs before removeprintln("The map elements before remove: " + map);//map after remove 3rd elementprintln("The value against 3rd element: " + map.remove(3));println("The map elements after 3rd element remove: " + map);//map after remove 0th element which is not present in mapprintln("The value against 0th element: " + map.remove(0));println("The map elements after 0 element remove: " + map);}