Functions in Dart

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

The Importance of Cybersecurity in the Digital Age

 The Importance of Cybersecurity in the Digital Age Introduction: In today's digital age, where technology is deeply intertwined with ev...