Fix the end of the third section in docs/gettingstarted.md (+ the Hello World code blocks), and add a note about primitive types.
This commit is contained in:
parent
34777acc74
commit
6d2314af06
|
@ -1,14 +1,14 @@
|
|||
## 1 - Variables
|
||||
Variables defined using #= can't be changed (they are "final"), while the ones affected using the normal operator (=) can.
|
||||
```
|
||||
helloworld #= "Hello World"
|
||||
helloworld #= "Hello, World!"
|
||||
```
|
||||
|
||||
## 2 - (Anonymous) Functions
|
||||
You can make an anonymous functions using the following syntax:
|
||||
```
|
||||
getHelloWorld: ~String => {
|
||||
return "Hello World!"
|
||||
return "Hello, World!"
|
||||
}
|
||||
```
|
||||
<sub>`~String` can be omitted, see [#3](#3---types).</sub>
|
||||
|
@ -32,13 +32,15 @@ as_main helloWorld >> {}
|
|||
## 3 - Types
|
||||
Types are *inferred*, which means that specifying types of variables or returned values is optional.
|
||||
|
||||
<sup>Note: While primitives types (`String`, `int`, `double`, `boolean`, `float`) will be transpiled to their equivalents for the target of the transpiler, this is not the case for other types.<sup>
|
||||
|
||||
Every variable has a static type by default; it is possible to make a **non-final** variable dynamic by adding the `dyn`/`dynamic` attribute:
|
||||
```
|
||||
dyn helloWorld = 0
|
||||
helloWorld = "Hello World!"
|
||||
helloWorld = "Hello, World!"
|
||||
```
|
||||
The attributes mentioned above can also be used as a return type for functions/anonymous functions:
|
||||
```
|
||||
helloWorld: ~dynamic => {}
|
||||
dyn helloWorld >> {}
|
||||
helloWorld: ~dynamic => { return 0 }
|
||||
dyn helloWorld >> { return 0 }
|
||||
```
|
Loading…
Reference in New Issue