| 1 |
import ballerina/io; |
| 2 |
|
| 3 |
// This function definition has two parameters of type `int`. |
| 4 |
// `returns` clause specifies type of return value. |
| 5 |
function add(int x, int y) returns int { |
| 6 |
|
| 7 |
int sum = x + y; |
| 8 |
// `return` statement returns a value. |
| 9 |
return sum; |
| 10 |
|
| 11 |
} |
| 12 |
|
| 13 |
public function main() { |
| 14 |
io:println(add(5, 11)); |
| 15 |
} |
| 16 |
import ballerina/io; |
| 17 |
|
| 18 |
// This function definition has two parameters of type `int`. |
| 19 |
// `returns` clause specifies type of return value. |
| 20 |
function add(int x, int y) returns int { |
| 21 |
|
| 22 |
int sum = x + y; |
| 23 |
// `return` statement returns a value. |
| 24 |
return sum; |
| 25 |
|
| 26 |
} |
| 27 |
|
| 28 |
public function main() { |
| 29 |
io:println(add(5, 11)); |
| 30 |
} |
| 31 |
|
| 32 |
// From https://ballerina.io/learn/by-example/functions |