Lambda Expressions

A lambda expression is a procedure without a name that you can use as an alternative to a named event handler. You can write a lambda expression on one line or as a block of statements. Lambda expressions can use the semantics of one of the statements Function or Sub. A lambda expression with the semantics of Sub has access to the local scope.

You make a lambda expression with one of the keywords Function or Sub, almost the same as the statements that use these keywords. The difference is that lambda expressions are a part of a statement.

In the example that follows, lambda expressions add to a value. The example shows the one-line and block constructs for a function.

Var add1 = Function(x) x + 1
Var add2 = Function(x)
        Return x + 2
    End Function

Print add1(1)
Print add2(2)
After run
2
4

Lambda expression syntax

The syntax of a lambda expression is almost the same as a typical procedure. The differences are as follows:

Context

TODO

See also