What is a closure in Scala?



What is a closure in Scala?..

Answer / Akash Yadav

A 'closure' in Scala (and other languages) refers to a function that has access to variables defined outside its immediate scope. This means that if a function captures and stores references to some of the local variables during its creation, it can still access these variables even when it is invoked later or passed as an argument to another function.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Scala Interview Questions

What are the Java’s OOP constructs not supported by Scala? What are the Scala’s OOP constructs not supported by Java? What are the new OOPs constructs introduced by Scala, but not supported by Java?

1 Answers  


Explain the operators in scala?

1 Answers  


What companies use scala?

1 Answers  


What is the difference between :: and #:: in Scala? What is the difference between ::: and #::: in Scala?

1 Answers  


What is function composition in scala?

1 Answers  


What is the use of ‘???’ in Scala-based Applications?

1 Answers  


What is a stream in scala?

1 Answers  


What is scala and why it is used?

1 Answers  


Explain exception handling in scala?

1 Answers  


What are the major differences between Scala’s Auxiliary constructors and Java’s constructors?

1 Answers  


What is an auxiliary constructor?

1 Answers  


What are the advantages of scala over java (java 8)?

1 Answers  


Categories