Skip to content

Commit 1f26389

Browse files
authored
Update LuaGlobals.yaml
Added an example function for usage of pcall()
1 parent 3ab4c98 commit 1f26389

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

content/en-us/reference/engine/globals/LuaGlobals.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,15 @@ functions:
346346
errors. In such case, `pcall()` also returns all results from the call,
347347
after this first result. In case of any error, `pcall()` returns false
348348
plus the error message.
349+
350+
```lua
351+
local function divideByFive(n: number)
352+
return n / 5
353+
end
354+
355+
local success, response = pcall(divideByFive, "ten")
356+
print(success, response)
357+
```
349358
parameters:
350359
- name: func
351360
type: function

0 commit comments

Comments
 (0)