Return function with multiple returns
Is it possible to return all of the return values from a "different" function that has multiple returns in a single return statement?
Like: Lua Code:
Lua Code:
or do you have to capture all of the returns and then return them like: Lua Code:
|
Yes, it works. If you call function in return statement, as a result you will get all return values from the called function.
Good example could be unpack() function. It is often called in return statement if you want to return values stored in array (table). lua Code:
|
Oh, I had a type-o no wonder I couldn't get it to work.
Thanks |
Or maybe it wasn't a type-o.
Does it still work if you do something like: Lua Code:
Sorry I should have just posted the actual code to begin with. The idea is to call one function GetMyItemInfo(..) to get an items info whether you pass in a bag,slot or link: Lua Code:
Lua Code:
|
Quote:
If you want to work with multiple return values in logical expression, you will have to store values to the table and then unpack it: Lua Code:
But this is probably better: Lua Code:
Lua Code:
Example: Lua Code:
|
Quote:
I tried the unpack (before I posted the question), but I guess I was doing it wrong too. I was trying to unpack each individual function call like: Lua Code:
Thanks for your help Garkin. |
All times are GMT -6. The time now is 10:22 PM. |
vBulletin © 2024, Jelsoft Enterprises Ltd
© 2014 - 2022 MMOUI