Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion tutorials/motoko_playground.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ actor Counter {

```

The actor has a stable variable counter, that will store the number of the counter and 3 public funcitons – get, set and inc. These functions form a public interface of our canister and we will see them in the generated Candid interface after deploy.
The actor has a stable variable counter, that will store the number of the counter and 3 public functions – get, set and inc. These functions form a public interface of our canister and we will see them in the generated Candid interface after deploy.

> Candid is an IDL (interface definition language) developed for the IC ecosystem in order to facilitate communication between services written in different programing languages. You can read more about it [here](https://medium.com/dfinity/candid-a-tool-for-interoperable-programming-languages-on-the-internet-computer-27e7085cd97f).

Expand Down
4 changes: 2 additions & 2 deletions tutorials/primitive_types.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ let b : Int = -10;
let c : Int = 1_000_000;
let d : Int = 0xf4; // 245
```
Let's make a little exercise now. Write a funciton called add, that will take two integers as arguments and return a sum of these two numbers.
Let's make a little exercise now. Write a function called add, that will take two integers as arguments and return a sum of these two numbers.
```
public query func add(a : Int, b : Int) : async Int {
return a+b;
Expand Down Expand Up @@ -135,7 +135,7 @@ let c : Text = "Hello, World!" // Ok
let d : Text = 'Hello, World!' // Not ok
```

Let's create a funciton concat, that will take two strings a and b as arguments and will return a concatenated text of them both with a single space between them.
Let's create a function concat, that will take two strings a and b as arguments and will return a concatenated text of them both with a single space between them.

```
public query func concat(a : Text, b : Text) : async Text {
Expand Down
8 changes: 4 additions & 4 deletions tutorials/understanding_types.md
Original file line number Diff line number Diff line change
Expand Up @@ -211,11 +211,11 @@ var days_mutable = Array.thaw<Text>(days);
```
Notice that some functions require to define the data type in the <> brackets.

Go through the base library and check what is inside for each type. These funcitons are going to save your time when writing your programs. However, please respect that Motoko is still quite a fresh language and there is not yet as many functions available as for more mature languages.
Go through the base library and check what is inside for each type. These functions are going to save your time when writing your programs. However, please respect that Motoko is still quite a fresh language and there is not yet as many functions available as for more mature languages.

#### Anonymous functions

Anonymous functions are also known as lambdas. You define them for generic purpose in your program to complete small tasks. They are not ment to be part of the public interface.
Anonymous functions are also known as lambdas. You define them for generic purpose in your program to complete small tasks. They are not meant to be part of the public interface.
```
func add(x : Int, y : Int) : Int = x + y;
```
Expand Down Expand Up @@ -268,12 +268,12 @@ let person2 : Person = {
var partner = ?person1; // in real situation, we should also update the status of person1 and person2 and set partner for person1 if the relationship is symmetrical
};
```
Optional values play significant roles also in function definitions as funciton can as well expect or return a null value. There will be more detailed tutorial on that soon.
Optional values play significant roles also in function definitions as function can as well expect or return a null value. There will be more detailed tutorial on that soon.

## Useful links and resources

Motoko Bootcamp video about variables, functions and types by Albert Du
https://www.youtube.com/watch?v=4YX41Nm7Wx8

Motoko Bootcamp video about variants by Paul Young
https://www.youtube.com/watch?v=GFenqSGhj7I&
https://www.youtube.com/watch?v=GFenqSGhj7I&