![scala-snippet (1)](http://www.codebind.com/wp-content/uploads/2017/10/scala-snippet-1.png)
A closure is a function which uses one or more variables declared outside this function.
// Scala - Closures /* codebind.com */ import java.util.Date object Demo { val number = 10; val add = (x : Int) => { x + number; } def main(args: Array[String]) { println(add(20)); println(number) } }
Leave a Reply