Functions and Records
Functions
Typed Return
A function declares its parameter and return types. return exits with a value.
Program
Play the program to add tax to a subtotal.
functions.dart
int addTax(int price) {
return price + price ~/ 10;
}
void main() {
var subtotal = 25;
var total = addTax(subtotal);
print(total);
}
typed signature
`int addTax(int price)` declares parameter and return types.
return
`return` exits the function with a value.
integer division
`price ~/ 10` is integer division for whole-cent rounding.