Y en Lua, ¿cómo se procesa?
Vi este código en unLua Style Guide
print(x == "yes" and "YES!" or x)
Contexto:
local function test(x)
print(x == "yes" and "YES!" or x)
-- rather than if x == "yes" then print("YES!") else print(x) end
end
¿Qué sucede exactamente en "x ==" yes "y" YES! "¿Por qué imprime" YES! "O (x) no" true "o (x)?
EDITAR:
Es como:
X == "yes" -- > true
true and (value) -- > value
print( (x == "yes") and value)
Entonces, verificar x para el valor "sí" da como resultado verdadero, agregar verdadero a un valor da el valor e imprimir este proceso imprime el valor, ¿verdad?