Skip to content

Instantly share code, notes, and snippets.

@ntatko
Created June 17, 2022 17:29
Show Gist options
  • Select an option

  • Save ntatko/cd427d1a545660b02119b313e26997e9 to your computer and use it in GitHub Desktop.

Select an option

Save ntatko/cd427d1a545660b02119b313e26997e9 to your computer and use it in GitHub Desktop.
A basic introduction to functions in dart
/// FUNCTIONS
void main() {
int sum = add(1, 3);
print("$sum"); // 4
logger("stuff"); // stuff
int starting = 0;
double ending = toDouble(starting);
print("${ending is double}"); // 0.0
}
/// Add to [int]s together
int add(int num1, int num2) {
int summary = num1 + num2;
return summary;
}
/// Log a [String]
void logger(String toLog) {
print(toLog);
}
/// Turn an [int] to a [double]
double toDouble(int integer) {
return integer.toDouble();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment