Skip to content

Instantly share code, notes, and snippets.

@pandanote-info
Created August 27, 2019 22:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pandanote-info/a6b91a5776ba77b611fb932729d1b380 to your computer and use it in GitHub Desktop.
Save pandanote-info/a6b91a5776ba77b611fb932729d1b380 to your computer and use it in GitHub Desktop.
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