lua tonumber() 函数的奇怪行为

当我使用 tonumber() 函数时,数值会变成 nil?

luxValue = otherdevices['Lux Woonkamer']
print("光强:" .. luxValue)

光强:55

luxValue = otherdevices['Lux Woonkamer']--仍然是 55
print("光强:" .. tonumber(luxValue))

尝试连接一个 nil 值

luxValue = tostring(otherdevices['Lux Woonkamer'])--仍然是 55
print("光强:" .. tonumber(luxValue))

尝试连接一个 nil 值

有人可以解释吗?

点赞