在 Lua 中,你可以这样做:
foo = a and b or c and d or e
相当于(至少我很确定它相当于):
local foo = nil
if a then
foo = b
elseif c then
foo = d
else
foo = e
end
在 C++ 中是否有与此等效或相似的东西?
最佳答案
我想这就是你想要的:
foo = a ? b : (c ? d : e );
关于c++ - 相当于C++中的Lua "and/or"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10765209/