# Anonymous functions

## Anonymous functions

() {
codeBlock;
};
var list = ['apples', 'bananas', 'oranges'];
list.forEach((item) {
print('${list.indexOf(item)}:$item');
});
list.forEach(
(item) => print('${list.indexOf(item)}:$item'));

You can also create a nameless function called an anonymous function, or sometimes a lambda or closure.

You might assign an anonymous function to a variable so that, for example, you can add or remove it from a collection.

## Related concepts

Anonymous functions

## Anonymous functions — Structure map

Clickable & Draggable!