From 8a2cb2ad62481b0f12ce0cf015960f3ea8547e19 Mon Sep 17 00:00:00 2001 From: boyned//Kampfkarren Date: Mon, 29 Nov 2021 18:47:26 -0800 Subject: [PATCH] Specify function return output --- rfcs/syntax-safe-navigation-operator.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/rfcs/syntax-safe-navigation-operator.md b/rfcs/syntax-safe-navigation-operator.md index 634b61c0..ee272fef 100644 --- a/rfcs/syntax-safe-navigation-operator.md +++ b/rfcs/syntax-safe-navigation-operator.md @@ -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