lua 函数 默认值_定义函数参数的默认值-CSDN博客

网站介绍:文章浏览阅读2.4k次。如果你想要命名参数和默认值,如PHP或Python,你可以使用表构造函数调用你的函数:myfunction{a,b=3,c=2}函数本身可以有这样的签名:function myfunction(t)setmetatable(t,{__index={b=7,c=5}})local a,c =t[1] or t.a,t[2] or t.b,t[3] or t.c-- function continue..._lua 函数参数默认值