From 2addcaf76bdddc7f5df2ad4bc6392166124fcdea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Buckwalter?= Date: Wed, 22 Jan 2025 17:45:52 +0100 Subject: [PATCH] Remove gratuitous parentheses in examples --- doc/manual.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/doc/manual.md b/doc/manual.md index 7ec239a0..bb4555e5 100644 --- a/doc/manual.md +++ b/doc/manual.md @@ -195,7 +195,7 @@ As an example, consider the same `sum_list` function from above written without local function iter(arr: {any}, prev: integer): (any, any) local i = prev + 1 local x = arr[i] - if x == (nil as any) then + if x == nil as any then return nil, nil end @@ -260,8 +260,8 @@ Pallene also allows you to downcast from `any` to other types. This is checked at run-time, and may result in a run-time type error. ```lua -local v = (17 as any) -local s = (v as string) -- run-time error: v is not a string +local v = 17 as any +local s = v as string -- run-time error: v is not a string ``` The `any` type allows for a limited form of dynamic typing. @@ -280,7 +280,7 @@ The reason for this is that, for performance, Pallene must know at compile-time ```lua local function f(x: any, y: any): integer - return (x as integer) + (y as integer) + return x as integer + y as integer end ``` @@ -405,7 +405,7 @@ For expressions the colon is already used for method calls, so Pallene uses the ```lua function foo(x : any) : integer - local y: integer = (x as integer) + local y: integer = x as integer return y + y end ```