例如,
function test (a)
name = nameof(a)
print(name)
end
test(def) --should print "def"
是否有实现上述类似目的的技巧?
并不是任何人都需要解释为什么要做某事;如果没有给出真实的例子,有些人会变得脾气暴躁。所以:
local function registerTestSuite(suite)
if (LUnit) then
LUnit:AddTestSuite(
HotNReady.."_"..GetVariableName(suite), --HotNReady_PizzaTestSuite
suite);
end;
end;
最佳答案
您所要求的是在纯粹的Lua中是不可能的。
如果真的需要此功能,请尝试摆弄Metalua。
关于string - Lua:获取参数的文字名称,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/1416815/