Update syntax.md (#45)

Add information about type ascription syntax
This commit is contained in:
Arseny Kapoulkine 2021-06-02 12:14:24 -07:00 committed by GitHub
parent 2a29ba1538
commit b490373454
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -117,6 +117,12 @@ function foo(x: number, y: string): boolean
end
```
In addition, the type of any expression can be overridden using a type cast `::`:
```lua
local k = (y :: string):rep(x)
```
There are several simple builtin types: `any` (represents inability of the type checker to reason about the type), `nil`, `boolean`, `number`, `string` and `thread`.
Function types are specified using the arguments and return types, separated with `->`: