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() endWhere 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
Uh oh!
There was an error while loading. Please reload this page.
-
I have a function that will always return either
falseand an error message ortrueand an array of results. Currently, I'm doing this:When I actually call the function, I'm only checking the
successboolean and not explicitly type checkingresults_or_error. Ifsuccessis false, it treatsresults_or_erroras a string, and whensuccessis true,results_or_erroris 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