Lua没有switch语句,我们就给它加一个:
一、简单的switch:
function switch(SwitchVal)
return function(SwitchTable)
local ReFunc = SwitchTable[SwitchVal]
if type(ReFunc) ~= "function" then
ReFunc = SwitchTable[ReFunc] or SwitchTable.default
end
return ReFunc and ReFunc()
end
end
优点是实...