Inline conditions in Lua (a == b ? "yes" : "no")?

Softnux picture Softnux · Apr 2, 2011 · Viewed 52.1k times · Source

Is there anyway to use inline conditions in Lua?

Such as:

print("blah: " .. (a == true ? "blah" : "nahblah"))

Answer

John Zwinck picture John Zwinck · Apr 2, 2011

Sure:

print("blah: " .. (a and "blah" or "nahblah"))