Skip to content

Instantly share code, notes, and snippets.

@makiftutuncu
Created November 29, 2015 21:09
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 makiftutuncu/eef93441d323ad4b7d7e to your computer and use it in GitHub Desktop.
Save makiftutuncu/eef93441d323ad4b7d7e to your computer and use it in GitHub Desktop.
Neden Scala? yazısı için örnek Scala kodu
case class Insan(yas: Int)
object NedenScala {
def main(args: Array[String]) {
val insanlar = for (i <- 1 to 10) yield Insan(scala.util.Random.nextInt(30) + 5)
println("İnsanlar:")
insanlar foreach println
println("Yaşları toplamı:")
println(insanlar.foldLeft(0)(_ + _.yas))
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment