Login using Social Account
     Continue with GoogleLogin using your credentials
A closure is a function, whose return value depends on the value of one or more variables declared outside this function.
A closure also works as a variable.
Example 1:
val multiplier = (i:Int) => i * 10
Example 2:
var factor = 3
val multiplier = (i:Int) => i * factor
Example 3:
object Hello {
def main(args: Array[String]) {
println( "multiplier(1) value = " + processme(1) )
println( "multiplier(2) value = " + processme(2) )
}
var factor = 4
val processme = (i:Int) => i * (factor+1)
}
Taking you to the next exercise in seconds...
Want to create exercises like this yourself? Click here.
No hints are availble for this assesment
Answer is not availble for this assesment
Loading comments...