Don't miss an insight. Subscribe to Techopedia for free.


Lambda Expression

What Does Lambda Expression Mean?

A lambda expression is an anonymous function that provides a concise and functional syntax, which is used to write anonymous methods. It is based on the function programming concept and used to create delegates or expression tree types. The syntax is function(arg1, arg2…argn) expression.


Techopedia Explains Lambda Expression

Lambda expressions use the operator symbol =, which reads as "goes to." Input parameters are specified on the operator’s left side, and statement/expressions are specified on the right. Generally, lambda expressions are not directly used in query syntax but are often used in method calls. Query expressions may contain method calls.

Lambda expression syntax features are as follows:

  • It is a function without a name.
  • There are no modifiers, such as overloads and overrides.
  • The body of the function should contain an expression, rather than a statement.
  • May contain a call to a function procedure but cannot contain a call to a subprocedure.
  • The return statement does not exist.
  • The value returned by the function is only the value of the expression contained in the function body.
  • The End function statement does not exist.
  • The parameters must have specified data types or be inferred.
  • Does not allow generic parameters.
  • Does not allow optional and ParamArray parameters.

Lambda expressions provide shorthand for the compiler, allowing it to emit methods assigned to delegates. The compiler performs automatic type inference on the lambda arguments, which is a key advantage.


Related Terms