scala foreach code example
Example 1: foreach loop in scala
scala> val x = List(1,2,3)
x: List[Int] = List(1, 2, 3)
scala> x.foreach { println }
1
2
3
Example 2: scala iterator foreach
it foreach println
scala> val x = List(1,2,3)
x: List[Int] = List(1, 2, 3)
scala> x.foreach { println }
1
2
3
it foreach println