Change the syntax for anonymous functions in docs/gettingstarted.md
Signed-off-by: Username404 <w.iron.zombie@gmail.com>
This commit is contained in:
parent
00a8fbaa83
commit
1d3046892f
|
@ -7,15 +7,13 @@ helloworld #= "Hello, World!"
|
|||
## 2 - (Anonymous) Functions
|
||||
You can make an anonymous functions using the following syntax:
|
||||
```
|
||||
getHelloWorld: ~String => {
|
||||
getHelloWorld: ~String #= {
|
||||
return "Hello, World!"
|
||||
}
|
||||
```
|
||||
The type (`~String` here, which basically means "an anonymous function that returns a String") can be omitted, see [#3](#3---types).
|
||||
|
||||
Note that you can make `getHelloWorld` final by replacing `=>` with `#=>`.
|
||||
|
||||
To define a **named** (and mandatorily final) function, replace `=>` with `>>`:
|
||||
To define a **named** (and mandatorily final) function, replace `#=` with `>>`:
|
||||
```
|
||||
getHelloWorld: String >> {
|
||||
return "Hello, World!"
|
||||
|
@ -25,7 +23,7 @@ getHelloWorld: String >> {
|
|||
### 2.1 - Main
|
||||
Main can be a variable named `main` that contains an anonymous function, a function named `main` or a function that has the `as_main` attribute:
|
||||
```
|
||||
main #=> {}
|
||||
main #= {}
|
||||
main >> {}
|
||||
as_main helloWorld >> {}
|
||||
```
|
||||
|
@ -33,7 +31,7 @@ as_main helloWorld >> {}
|
|||
### 2.2 - Function parameters
|
||||
Parameters can be added to an anonymous function by specifying the types as follows:
|
||||
```
|
||||
addIntToString (int, String) => { a, b;
|
||||
addIntToString: (int, String)~ #= { a, b;
|
||||
print_line(b + a)
|
||||
}
|
||||
```
|
||||
|
|
Loading…
Reference in New Issue