1.

Explain the function Currying in Scala.

Answer»

In Scala, currying refers to the technique of transforming a function. There are multiple arguments passed into this function, which then forms a chain of functions that take one argument each. This type of function is widely used in multiple functional languages. 

 Syntax:

def curryfunction_name(argument1, argument2) = operation

Example: 

object Currying { def add(a: Int, B: Int) = a + b; def main(args: Array[String]) { println(add(10, 5)); } }

Output: 

15

In this case, we've DEFINED an add function that TAKES two arguments (a and b), and it gives US the result of adding a and b, by calling it in the main function. 



Discussion

No Comment Found