Title here
Summary here
Lua has support for multiple return values. This feature is commonly used in idiomatic Lua, for example, to return both result and error values from a function.
To run the program, save it as multiple_return_values.lua
and use the lua
command:
In Lua, functions can return any number of values, and multiple assignment allows you to easily capture these values. If you don’t need all the returned values, you can simply omit the variables for the ones you don’t need, which is similar to using the blank identifier in other languages.
Returning multiple values is another nice feature of Lua functions; we’ll explore more Lua features in the upcoming examples.