DEV Community

Cover image for Lambda Functions in Dart
Baransel
Baransel

Posted on

Lambda Functions in Dart

Every function in dart is an object.

Functions that we use very often without a name are also called lambda functions.

Lambda functions are also called Arrow functions.

You can see usage example and output below.

Lambda Function Example Code

Follow my blog for more baransel.dev.

Top comments (3)

Collapse
 
nombrekeff profile image
Keff

Just wanted to clear something up. What is showcased in the example are not lambdas/anonymous functions, they are arrow functions. Although lambdas usually use the arrow syntax.

Arrow syntax function:

int test() => 123;
Enter fullscreen mode Exit fullscreen mode

Anonymous/lambda function:

items.map((item) => item.value);
Enter fullscreen mode Exit fullscreen mode
Collapse
 
baransel profile image
Baransel • Edited

Lambda functions are also called Arrow functions.

Collapse
 
nombrekeff profile image
Keff

Correct, lambdas use the arrow syntax, but at least in dart they only refer to anonymous/closure functions as lambdas. I've not seen arrow functions refered as such, at least in the dart language. Though they're called that in some other languages.

PD: no need to scream 😜