Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
下面的函数是否正确?
local function yes() return 1 end local function no() return 0 end
可以用这种方式设置变量的值吗?
local May_I = yes() if May_I ~= 0 then -- Yes I can do that end
我喜欢数字,但有时它们不是很精确。
您可以像这样处理您提到的不精确性:
> epsilon = 1e-2 > function yes() >> return 1 >> end > if math.abs( yes() - 1 ) <= epsilon then >> print("Yes I can") >> end Yes I can
或者,要精确并使用trueand false。
true
false