From ecdc209523f011b5fb4a0fee3a8e867da9c53fb5 Mon Sep 17 00:00:00 2001 From: jinhua luo Date: Fri, 21 Oct 2022 13:47:54 +0800 Subject: [PATCH] docs: specify function return value (#8115) --- CODE_STYLE.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/CODE_STYLE.md b/CODE_STYLE.md index e7a00bc13a46..9b25f552cf90 100644 --- a/CODE_STYLE.md +++ b/CODE_STYLE.md @@ -320,6 +320,24 @@ local function check(age, name) end ``` +The function should return ``, `err`. +The first return value means successful or not, if not, the second return value specifies the error message. +The error message can be ignored in some case. + +```lua +--No +local function check() + return "failed" +end +``` + +```lua +--Yes +local function check() + return false, "failed" +end +``` + ## Module All require libraries must be localized: