Fix function type annotation grammar in docs. (#5)

This commit is contained in:
Alexander 2020-08-11 16:56:07 -07:00 committed by GitHub
parent 3be82035bf
commit 8e38c0ec7d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 2 deletions

View File

@ -128,7 +128,7 @@ local array: { [number] : string }
local object: { x: number, y: string }
```
Additionally, the type syntax supports type intersections (`(number) -> string & (boolean) -> string`) and unions (`(number | boolean) -> string`). An intersection represents a type with values that conform to both sides at the same time, which is useful for overloaded functions; a union represents a type that can store values of either type - `any` is technically a union of all possible types.
Additionally, the type syntax supports type intersections (`((number) -> string) & ((boolean) -> string)`) and unions (`(number | boolean) -> string`). An intersection represents a type with values that conform to both sides at the same time, which is useful for overloaded functions; a union represents a type that can store values of either type - `any` is technically a union of all possible types.
It's common in Lua for function arguments or other values to store either a value of a given type or `nil`; this is represented as a union (`number | nil`), but can be specified using `?` as a shorthand syntax (`number?`).

View File

@ -227,7 +227,7 @@ local vec3: Vector3 = {x = 1, y = 2, z = 3} -- ok
```
```lua
type SimpleOverloadedFunction = (string) -> number & (number) -> string
type SimpleOverloadedFunction = ((string) -> number) & ((number) -> string)
local f: SimpleOverloadedFunction