Tsallaka zuwa abun ciki
Justice Tech School

Dart Functions

A function has a return type, a name and parameters. Arrow syntax => returns a single expression. void means nothing is returned.

Example
int add(int a, int b) => a + b;
void greet(String name) { print("Hello $name"); }
void main() {
  print(add(2, 3));
  greet("Ada");
}

Exercise

Arrow syntax.

int sq(int x)  x * x;

Quiz Test

What does => do?

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