字典类型¶
注解
可以利用 table<KEY_TYPE, VALUE_TYPE>
的方式来标注一个数据类型为字典
- 完整格式:
---@type table<KEY_TYPE, VALUE_TYPE>
示例:
1 2 3 4 5 6 7 8 9
---@type table<string, Car> local dict = {} local car = dict['key'] -- car. and you'll see completion for key, car in pairs(dict) do -- car. and you'll see completion end
参见