@return 函数返回值注解¶
注解
利用 @return
注解来标记函数的返回值类型
- 完整格式:
---@return MY_TYPE[|OTHER_TYPE] [@comment]
应用目标:
- 函数
1 2 3 4 5 6 7
---@return Car|Ship local function create() ... end ---Here car_or_ship doesn't need @type annotation, EmmyLua has already inferred the type via "create" function local car_or_ship = create()
1 2 3 4
---@return Car function factory:create() ... end