The process of traversing foreach by Scala
This article mainly introduces "Scala traversing foreach process". In daily operation, I believe many people have doubts about Scala traversing foreach process. Xiaobian consulted various materials and sorted out simple and easy operation methods. I hope to help you answer the doubts of "Scala traversing foreach process"! Next, please follow the small series to learn together!
##traverse foreach
list traversal
var l = List(1,2,3,4,5)l.foreach(i=>println(i))
map traversal
var m = Map("tony" -> 80, "bob" -> 90) m.foreach(kv => println(kv._ 1, kv._ 2))
##Map
val l = List("hive","hadoop","spark") val books= l.map(s=>s.toUpperCase) for(x s.toList) for(x