Anonymous (lambda) functions

// small one line functions that dont have name
int add(a,b) => a+b;
// lambda functions mostly passed as parameter to other functions
const list = ['apples', 'bananas', 'oranges'];
list.forEach(
(item) => print('${list.indexOf(item)}: $item'));
//Prints: 0: apples 1: bananas 2: oranges
Comments