feat: add examples with descriptions
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
// If you have some code section which is
|
||||
// duplicated in program several times
|
||||
// then it means your program needs some
|
||||
// functions!
|
||||
|
||||
fn doSomeWork()
|
||||
{
|
||||
printline("Some work");
|
||||
}
|
||||
|
||||
// If the function makes some kind of
|
||||
// calculations then you should specify
|
||||
// the result type
|
||||
|
||||
fn sum(int a, int b) int
|
||||
{
|
||||
return a + b;
|
||||
}
|
||||
|
||||
// The `return` keyword can be used to
|
||||
// actually return the value from the
|
||||
// function. Also, you can specify list
|
||||
// of arguments that you will use inside
|
||||
// the function
|
||||
|
||||
int first = 5;
|
||||
int second = 6;
|
||||
int result = sum(first, second);
|
||||
printline(result);
|
||||
|
||||
Reference in New Issue
Block a user