mirror of
https://github.com/luau-lang/luau.git
synced 2025-05-04 10:33:46 +01:00
Specify function return output
This commit is contained in:
parent
d2cb1d784b
commit
8a2cb2ad62
1 changed files with 12 additions and 0 deletions
|
@ -89,6 +89,18 @@ When using safe navigation to call a function, the short circuiting will prevent
|
|||
object?.doSomething(getValue())
|
||||
```
|
||||
|
||||
This will return one `nil` if the object was nil.
|
||||
|
||||
```lua
|
||||
function Class:returnTwoValues()
|
||||
return 1, 2
|
||||
end
|
||||
|
||||
-- Assuming `object` is `Class`, and `nilObject` is nil
|
||||
print(object?:returnTwoValues()) -- 1, 2
|
||||
print(nilObject?:returnTwoValues()) -- nil
|
||||
```
|
||||
|
||||
The short-circuiting is limited within the expression.
|
||||
|
||||
```lua
|
||||
|
|
Loading…
Add table
Reference in a new issue