Positional vs Named Parameters
Call functions with clear, ordered or labeled args.
Two Ways to Pass Args
Dart offers two parameter styles: positional and named. Picking the right one makes your function calls clearer and harder to misuse.
Positional Parameters
Positional parameters are matched by order. The first value fills the first slot, the second fills the second, and so on.
int sub(int a, int b) {
return a - b;
}
sub(10, 3); // 7All lessons in this course
- Declaring Functions and Return Types
- Positional vs Named Parameters
- Default Values and required
- Functions as First-Class Values