【发布时间】:2017-06-03 02:49:37
【问题描述】:
我已经和 Lua 搞混了几天,我发现了一些让我三思而后行的事情。 Lua 5.3 的参考手册我还没有阅读,因为它看起来很复杂,我会尽快检查它。
好的,在 lua 5.3 中,我们知道 print() 返回 nil 并打印一个空格。
>print(print(print()))
--this prints three spaces
--but print() returns nil so print(nil) should
--print nil. But instead it is printing 3 spaces
>print(type(2))
number --this prints a number since type(2) returns a
--number , but this doesn't work with print(print())
--why?
【问题讨论】:
-
print 没有返回任何内容。所以
print(print())等于print() print()