Skip to content
Justice Tech School

Closures and Function Types

Functions are objects. Closures capture variables.

Example
Function makeAdder(int n) => (int x) => x + n;
var add5 = makeAdder(5);
print(add5(10));
int Function(int) twice = (x) => x * 2;
print(twice(4));

Exercise

Function type.

int (int) f

Quiz Test

What do closures capture?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.