Skip to content

Latest commit

 

History

History
38 lines (25 loc) · 674 Bytes

File metadata and controls

38 lines (25 loc) · 674 Bytes

@generic generic annotation

Note

Use @generic to simulate generic in some high-level languages

  • Full format
--@generic T1 [: PARENT_TYPE] [, T2 [: PARENT_TYPE]]
  • Target:

    • function
  • Examples:

    ---@generic T : Transport, K
    ---@param param1 T
    ---@param param2 K
    ---@return T
    local function test(param1, param2)
        -- todo
    end
    
    ---@type Car
    local car = ...
    
    local value = test(car)
    /images/annotation/generic.png