Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
ScalaのHelloWorld的なコード。foreachの使用例です。
object HelloMain {
def main(args: Array[String]) = {
var sum: Int = 0
(1 to 10).foreach( s => ((x: String) => println(x))(s.toString) )
(1 to 10).foreach( s => ((x: Int) => {
sum += x
println(sum.toString)
})(s))
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.