LUA : 매개 변수의 문자 이름을 얻으십시오
문제
예를 들어,
function test (a)
name = nameof(a)
print(name)
end
test(def) --should print "def"
위와 비슷한 것을 구현할 Lua 트릭이 있습니까?
누구나 설명 할 필요는 없습니다 왜 그들은 무언가를하고 싶어합니다. 어떤 사람들은 실제 모범이 없으면 심술 궂습니다. 그래서:
local function registerTestSuite(suite)
if (LUnit) then
LUnit:AddTestSuite(
HotNReady.."_"..GetVariableName(suite), --HotNReady_PizzaTestSuite
suite);
end;
end;
해결책
당신이 요구하는 것은 순수한 루아에서는 불가능합니다.
만약 너라면 진짜 이 문제가 필요합니다 Metalua.
다른 팁
사용해보십시오 디버그 라이브러리.
당신이 사용할 수있는 debug.getlocal ([thread,] level, local)
이름을 포함하여 로컬 변수에 대한 정보를 얻으려면
제휴하지 않습니다 StackOverflow