scala

Scala Partially Applied Functions

When you invoke a function, you’re said to be applying the function to the arguments. If you pass all the expected arguments, you have fully applied it. If you send only a few arguments, then you get back a partially applied function. This gives you the convenience of binding some arguments and leaving the rest to be filled in later. Following is a simple example to show the concept for Scala Partially Applied Functions

For Video : Click Here

object partapplied {
  val add = (a: String, b: String) => a + b
  val email = add(_: String, "@abc.com")

  def main(args: Array[String]) {
    println(email("john"))
  }
}

Output
john@abc.com

Under score is used to denote the partially applied function an best example is gmail sign-in in user name column we are specifying only the user name not the whole domain name any how that is optional.

For example my mail id is : “godatafy@gmail.com” instead i can give just “godatafy” so that means it was partially applied.