Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Equivalent to Lua "and/or" in C++?

Tags:

c++

lua

In Lua, you can do this:

foo = a and b or c and d or e

Which is equivalent to (at least I am pretty sure it is equivalent to):

local foo = nil
if a then
foo = b
elseif c then
foo = d
else
foo = e
end

Is there anything equivalent or similar to this in C++?

like image 629
pighead10 Avatar asked Jun 09 '26 00:06

pighead10


1 Answers

I guess this is what you want:

foo = a ? b : (c ? d : e );
like image 159
Hakan Serce Avatar answered Jun 10 '26 13:06

Hakan Serce