From 5bf0ca7db5c3489a275c71b36d04d6deef4f7e74 Mon Sep 17 00:00:00 2001 From: Vyacheslav Egorov Date: Tue, 30 Nov 2021 20:06:16 +0200 Subject: [PATCH] Add a note about the difference between ...T and T... Fix a typo at the start as well. --- docs/_pages/typecheck.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/docs/_pages/typecheck.md b/docs/_pages/typecheck.md index cc2a13eb..c4e5efe8 100644 --- a/docs/_pages/typecheck.md +++ b/docs/_pages/typecheck.md @@ -289,7 +289,7 @@ type F = (...number) -> ...string ## Type packs -Multiple function return values as well as the function variadic parameter uses a type pack to represent a list of types. +Multiple function return values as well as the function variadic parameter use a type pack to represent a list of types. When a type alias is defined, generic type pack parameters can be used after the type parameters: @@ -297,7 +297,9 @@ When a type alias is defined, generic type pack parameters can be used after the type Signal = { f: (T, U...) -> (), data: T } ``` -Similarly, generic function can reference a generic type pack from the generics list: +> Keep in mind that `...T` is a variadic type pack (many elements of the same type `T`), while `U...` is a generic type pack that can contain zero or more types and they don't have to be the same. + +It is also possible for a generic function to reference a generic type pack from the generics list: ```lua local function call(s: Signal, ...: U...)