I want to make function which returns multiple variants "how to use function": var.get(a:number): any next is var.get(a:string,b:number): any next is var.get(): any.
I know by Roblox Lua (LuaU) it's possible and it returns as pages like I did upper. How can I make same? (please provide code) I'm sure it should be one function but how it returns multiple variants of how to use it?
I tried:
local var={}
function var.get(a:number):any
-- some code here
end
function var.get():any
-- some code here
end
But it didn't worked.
As @Kylaaa said, there is no function overloading in Lua out of the box. But Lua is flexible, and function overloading can be emulated, using already mentioned variadic functions and the fact that, in Lua, functons are first-class objects.