Update syntax.md (#46)

Add documentation for named arguments in function types.
This commit is contained in:
Arseny Kapoulkine 2021-06-02 13:19:46 -07:00 committed by GitHub
parent b20601af89
commit 50c22abae0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -142,6 +142,12 @@ function foo(x: number, y: number): (number, string)
end
```
Note that function types are specified without the argument names in the examples above, but it's also possible to specify the names (that are not semantically significant but can show up in documentation and autocomplete):
```lua
local callback: (errorCode: number, errorText: string) -> ()
```
Table types are specified using the table literal syntax, using `:` to separate keys from values:
```lua