ν¨μ
ν¨μ μ μ
νμ
λ©μλλͺ
( 맀κ°λ³μ1, 맀κ°λ³μ2 ) {
}
Dart
볡μ¬
β’
μμ μ½λ
int add(int a, int b) {
return a + b;
}
void main() {
print(add(3, 5)); // μΆλ ₯: 8
}
Dart
볡μ¬
μ΅λͺ ν¨μ
μ΅λͺ ν¨μ
( νμ
맀κ°λ³μ1, νμ
맀κ°λ³μ2 ) { }
Dart
볡μ¬
β’
μμμ½λ
var multiply = (int a, int b) {
return a * b;
};
void main() {
print(multiply(3, 5)); // μΆλ ₯: 15
}
Dart
볡μ¬
λλ€ ν¨μ
λλ€ ν¨μ μ μ
(νμ
맀κ°λ³μ1, νμ
맀κ°λ³μ2) => λ°νκ°;
Dart
볡μ¬
(νμ
맀κ°λ³μ1, νμ
맀κ°λ³μ2) => { μ€νλ¬Έ }
Dart
볡μ¬
(νμ
맀κ°λ³μ1, νμ
맀κ°λ³μ2) => { return λ°νκ°; }
Dart
볡μ¬
β’
μμ μ½λ
var multiply = (int a, int b) => a * b;
void main() {
print(multiply(3, 5)); // μΆλ ₯: 15
}
Dart
볡μ¬
μ¬κ· ν¨μ
ν¨μ μκΈ° μμ μ νΈμΆνλ ν¨μ
int factorial(int n) {
if (n == 0 || n == 1) {
return 1;
} else {
return n * factorial(n - 1);
}
}
void main() {
print(factorial(5)); // μΆλ ₯: 120
}
Dart
볡μ¬