From 094d5a0e090cdcc19d192118de186e4fadd08231 Mon Sep 17 00:00:00 2001 From: Arseny Kapoulkine Date: Wed, 31 Mar 2021 20:13:19 -0700 Subject: [PATCH] Update 2021-03-29-luau-recap-march-2021.md --- .../2021-03-29-luau-recap-march-2021.md | 20 +------------------ 1 file changed, 1 insertion(+), 19 deletions(-) diff --git a/docs/_posts/2021-03-29-luau-recap-march-2021.md b/docs/_posts/2021-03-29-luau-recap-march-2021.md index 76dff867..f91c93e8 100644 --- a/docs/_posts/2021-03-29-luau-recap-march-2021.md +++ b/docs/_posts/2021-03-29-luau-recap-march-2021.md @@ -32,25 +32,7 @@ end ## Generic functions -Luau has always supported type inference for generic functions, for example: -``` -type Point = { x: X, y: Y } -function swap(p) - return { x = p.y, y = p.x } -end -local p : Point = swap({ x = "hi", y = 37 }) -local q : Point = swap({ x = "hi", y = true }) -``` -but up until now, there's been no way to write the type of `swap`, since Luau didn't have type parameters to functions (just regular old data parameters). Well, now you can: -``` -function swap(p : Point): Point - return { x = p.y, y = p.x } -end -``` -Generic functions can be used in function declarations, and function types too, for example -``` -type Swapper = { swap : (Point) -> Point } -``` +**WARNING** Generic functions are currently disabled as we're fixing some critical bugs. ## Typechecking improvements