andremm / typedlua

An Optional Type System for Lua
563 stars 53 forks source link

argument defaults #110

Open tmbdev opened 7 years ago

tmbdev commented 7 years ago

I would find it useful if typedlua allowed defaults for arguments; this often is useful for being able to specify a more restrictive type, e.g. "string" instead of "string?"

function f(x:string="something"): string
    return x..x
end

instead of

function f(x: string?): string
    if x==nil then x = "something" end
    return x..x
end