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

Margaret Rouse

Margaret Rouse is an award-winning technical writer and teacher known for her ability to explain complex technical subjects to a non-technical, business audience. Over the past twenty years her explanations have appeared on TechTarget websites and she's been cited as an authority in articles by the New York Times, Time Magazine, USA Today, ZDNet, PC Magazine and Discovery Magazine.Margaret's idea of a fun day is helping IT and business professionals learn to speak each other’s highly specialized languages. If you have a suggestion for a new definition or how to improve a technical explanation, please email Margaret or contact her…