Skip to content

how to inform luals a table with __call() metamethod is also a function? #2168

Closed Answered by carsakiller
haolian9 asked this question in Q&A
Discussion options

You must be logged in to vote

If you need to define parameters and returns, it is recommended to use @overload

---@overload fun(a: string): boolean
local foo = setmetatable({}, {
	__call = function(a)
		print(a)
        return true
	end,
})

local bool = foo("myString")

Replies: 2 comments 5 replies

Comment options

You must be logged in to vote
3 replies
@haolian9
Comment options

@C3pa
Comment options

@haolian9
Comment options

Comment options

You must be logged in to vote
2 replies
@haolian9
Comment options

@carsakiller
Comment options

Answer selected by haolian9
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants