-
local ROUTER_MT = {}
ROUTER_MT.__index = ROUTER_MT
for _, method in ipairs({"get", "post"}) do
--- @function router:$method
ROUTER_MT[method] = function(self, path, ...)
-- ...
end
end |
Beta Was this translation helpful? Give feedback.
Answered by
tomlau10
Sep 8, 2024
Replies: 1 comment 2 replies
-
---@class Router
---@field [string] fun(self: Router. path: string, ...) |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
There seems no
1 line
way to add dynamically created function into a class definition. After all luals will not execute the actual forloop 😅 . I would suggest adding each method using@field
manually, like the following:In luals we can add annotation to the same class multiple times, so you may add these
@field
in different places. luals will be able to union them together: