Combinations of return values? #2601
Unanswered
ThePython10110
asked this question in
Q&A
Replies: 1 comment
-
the idomatic lua way, and how LuaLS is optimal for is by doing ---@return vector.Vector[]? results, string? error
local function some_func() end Where you can then do local ok, err = some_func() or local res = assert(some_func()) |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I have a function that will always return either
false
and an error message ortrue
and an array of results. Currently, I'm doing this:When I actually call the function, I'm only checking the
success
boolean and not explicitly type checkingresults_or_error
. Ifsuccess
is false, it treatsresults_or_error
as a string, and whensuccess
is true,results_or_error
is treated as a table. Unfortunately, the diagnostics don't know that...So... the point is, is there any way for the type checker to figure out what the other return values' types are if one is known? Something like this?
Beta Was this translation helpful? Give feedback.
All reactions