Created
August 27, 2019 22:26
-
-
Save pandanote-info/a6b91a5776ba77b611fb932729d1b380 to your computer and use it in GitHub Desktop.
ScalaのHelloWorld的なコード。foreachの使用例です。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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