jweinst1
4/19/2017 - 10:29 PM

using closures in scala

using closures in scala

//returns a function which captures a value
object add {
  //optional :Int => Int
  def capt(x:Int) = {
    (y:Int) => x + y
  }
}


object HelloWorld {
  def main(args: Array[String]): Unit = {
    val clos = add.capt(8);
    println(clos(3));
  }
}


HelloWorld.main(Array());