0

I have this code snippet:

val ln = List (1, 2, 3)

for (i <- ln){
  println(i*2)
  } 

Is it possible to write the same code but using the List.foreach method?

4

1 回答 1

3
ln.foreach(i => println(i*2))
于 2013-03-29T21:39:50.537 回答