Hey,
You can see this following code to print the key and values in Map:
for((key,value) <- colors) {
println(key)
println(value)
}
The iteration variable returns a tuple which is being assigned to two variables "key" and "value".
I hope it is clear.
To know more about Spark Scala, It's recommended to join Apache Spark training online today.
Thanks!!