为什么 type(nil)==nil 是假的?
Why type(nil)==nil is false?
我正在阅读“Lua 中的编程”一书,但我不理解练习 2.1:
What is the value of the expression
type(nil)==nil?
(You can use Lua to check your answer.) Can you explain this result?"
当我执行此代码时,结果为“false”。我无法解释这个结果,从我的角度来看正确的结果应该是“真”。我试过了
type(some_undeclared_variable)==nil
它也给了我“假”。
函数type()
总是returns一个字符串,type(nil)
的值为字符串"nil"
,与nil
不同,他们有不同的类型。
我正在阅读“Lua 中的编程”一书,但我不理解练习 2.1:
What is the value of the expression
type(nil)==nil?
(You can use Lua to check your answer.) Can you explain this result?"
当我执行此代码时,结果为“false”。我无法解释这个结果,从我的角度来看正确的结果应该是“真”。我试过了
type(some_undeclared_variable)==nil
它也给了我“假”。
函数type()
总是returns一个字符串,type(nil)
的值为字符串"nil"
,与nil
不同,他们有不同的类型。