我有这段代码:
function test()
function awesome()
print("im awesome!")
end
function notawesome()
print("im not awesome.")
end
function notevenawesome()
print("im not even awesome...")
end
end
test().notawesome()
当我运行它时,控制台会打印:
15: 试图索引一个空值
我的目的是在函数test()内调用函数notawesome(),我应该怎么做?
return
:function test() print("blah") end test()
? - crazicrafter1awesome
,notawesome
,notevenawesome
设置为局部变量,因为它们在test
函数外部没有使用,那么这个答案就可以得到改进。test
也可以被设置为局部变量,但这取决于设计。 - Tom Blodget