Functions in Dart
Functions are used to group a set of statements together that perform a specific task. In Dart, functions are defined using the void keyword for functions that do not return a value, and using the data type of the value returned for functions that return a value.
void main() {
printGreeting();
var result = multiply(5, 10);
print('Result: $result');
}
void printGreeting() {
print('Hello, World!');
}
int multiply(int a, int b) {
return a * b;
}
No comments:
Post a Comment