mirror of
https://github.com/krgamestudios/Toy.git
synced 2026-04-17 15:54:07 +10:00
Must force a type when dealing with compound types
This commit is contained in:
@@ -24,6 +24,7 @@ TODO: functions are first-class citizens
|
||||
TODO: functions last argument can be a rest parameter
|
||||
|
||||
TODO: && and || operators
|
||||
TODO: += -= *= /= %= operators
|
||||
TODO: A way to check the type of a variable (typeOf keyword)
|
||||
TODO: a = b = c = 1; ?
|
||||
TODO: are compounds shallow or deep copies?
|
||||
|
||||
10
docs/spec.md
10
docs/spec.md
@@ -118,6 +118,16 @@ var t: type = int;
|
||||
var u: t = 42;
|
||||
```
|
||||
|
||||
To force a type instead of an array, use the `type` keyword:
|
||||
|
||||
```
|
||||
var a = [type type]; //array of types
|
||||
var b = type [type]; //type of array of types
|
||||
var c = [type]; //error!
|
||||
|
||||
var d = b; //types can be re-assigned to other variables
|
||||
```
|
||||
|
||||
## Const
|
||||
|
||||
The "const" keyword can be appended to the type of a variable to fix the value in place - constants, as they're known, can't be changed once they are given a value at declaration.
|
||||
|
||||
Reference in New Issue
Block a user