数组类型

注解

可以利用 MY_TYPE[] 的方式来标注一个数据类型为数组

  • 完整格式:
---@type MY_TYPE[]
  • 示例:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    ---@type Car[]
    local list = {}
    
    local car = list[1]
    -- car. and you'll see completion
    
    for i, car in ipairs(list) do
        -- car. and you'll see completion
    end
    
Fork me on GitHub