You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Functions are first-class citizens, and should be assignable to bindings inline. These functions, which can be thought of as lambdas, can have bodies which "close over" variables.
Syntax
func getCounter() {
var count = 0
val inc = () => count = count + 1
val printCount = () => println("Count: " + count)
{
inc: inc,
printCount: printCount
}
}
val counter = getCounter()
counter.printCount() // Prints "Count: 0"
counter.inc()
counter.printCount() // Prints "Count: 1"
The text was updated successfully, but these errors were encountered:
While the syntax for lambdas has not yet been implemented, the functionality for closures to close over locals has been successfully implemented over the course of #83, #85, #86, #87, #88, and #95.
Functions are first-class citizens, and should be assignable to bindings inline. These functions, which can be thought of as lambdas, can have bodies which "close over" variables.
Syntax
The text was updated successfully, but these errors were encountered: