mirror of
https://github.com/luau-lang/luau.git
synced 2024-12-12 21:10:37 +00:00
Update typecheck.md
Add short hand array like type syntax
This commit is contained in:
parent
98402c3798
commit
ad9f2ac5d0
1 changed files with 2 additions and 0 deletions
|
@ -184,6 +184,8 @@ local t = {"Hello", "world!"} -- {[number]: string}
|
|||
print(table.concat(t, ", "))
|
||||
```
|
||||
|
||||
Luau supports a concise declaration for array-like tables, `{T}` (for example, `{string}` is equivalent to `{[number]: string}`); the more explicit definition of an indexer is still useful when the key isn't a number, or when the table has other fields like `{ [number]: string, n: number }`.
|
||||
|
||||
## Generics
|
||||
|
||||
The type inference engine was built from the ground up to recognize generics. A generic is simply a type parameter in which another type could be slotted in. It's extremely useful because it allows the type inference engine to remember what the type actually is, unlike `any`.
|
||||
|
|
Loading…
Reference in a new issue