How to overload indexing? #2442
-
I'm trying to write a definition file for a c++ class being loaded into a Lua environment, and one of my classes has an overloaded index operator. I can't seem to find anything in the github.io documentation on how to overload the index operator in particular. Does that feature exist already, and if so how do you write it? Thanks |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
Not sure if bumping is frowned upon here, but I still have not found an answer to this in documentation or previous discussions. Even if the answer is it not being a supported feature I'd love to take it off my todo list. |
Beta Was this translation helpful? Give feedback.
-
By index operator, do you mean something like this? ---@class Class
---@field bool boolean
---@field [string] integer
---@field [integer] string
local class
local bool = class.bool
local int = class.string
local str = class[3] |
Beta Was this translation helpful? Give feedback.
-
That is exactly it, thank you. Maybe my not being a Lua native is showing. |
Beta Was this translation helpful? Give feedback.
By index operator, do you mean something like this?