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:
Username404 2021-07-31 21:30:58 +02:00
parent 34777acc74
commit 6d2314af06
Signed by: Username404-59
GPG Key ID: 7AB361FBB257A5D1
1 changed files with 7 additions and 5 deletions

View File

@ -1,14 +1,14 @@
## 1 - Variables ## 1 - Variables
Variables defined using #= can't be changed (they are "final"), while the ones affected using the normal operator (=) can. 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 ## 2 - (Anonymous) Functions
You can make an anonymous functions using the following syntax: You can make an anonymous functions using the following syntax:
``` ```
getHelloWorld: ~String => { getHelloWorld: ~String => {
return "Hello World!" return "Hello, World!"
} }
``` ```
<sub>`~String` can be omitted, see [#3](#3---types).</sub> <sub>`~String` can be omitted, see [#3](#3---types).</sub>
@ -32,13 +32,15 @@ as_main helloWorld >> {}
## 3 - Types ## 3 - Types
Types are *inferred*, which means that specifying types of variables or returned values is optional. 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: 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 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: The attributes mentioned above can also be used as a return type for functions/anonymous functions:
``` ```
helloWorld: ~dynamic => {} helloWorld: ~dynamic => { return 0 }
dyn helloWorld >> {} dyn helloWorld >> { return 0 }
``` ```