1.

Define Closure in Scala with example?

Answer»

Define Closure in SCALA with example?
Closure is ONE of the FUNCTION define in Scala whose return value depends on the value of the variable declared OUTSIDE the closure function. Below is the example of closure function:-
Example 1:-


Closure Scala
Output:-
res45:Int = 25

Example 2:-


Closure Scala Example
Output
res46:Int = 35

In example 2 mul2 takes the new value of 'C' when it is second time.



Discussion

No Comment Found