Last Updated: February 25, 2016
·
592
· amirtcheva

Foreach and counting in Scala

Was looking for the equivalent of Ruby's:
ruby (1..5).each {|x| puts x }
or:
ruby (1.upto(5)).each {|x| puts x}

in Scala, and found that:
scala (1.to(10)).foreach { println }

results in the same output. Cool!