0Pricing
Dart Academy · Lesson

Functions as First-Class Values

Pass and return functions like data.

Functions Are Values

In Dart, a function is a first-class value, just like a number or string. You can store it, pass it, and return it. 🎁

Storing a Function

Assign a function to a variable by using its name without parentheses. The variable now points to the function itself.

int triple(int x) => x * 3;
var f = triple;
f(4); // 12

All lessons in this course

  1. Declaring Functions and Return Types
  2. Positional vs Named Parameters
  3. Default Values and required
  4. Functions as First-Class Values
← Back to Dart Academy