Quantcast
Channel: Lua, if statement idiom - Stack Overflow
Browsing latest articles
Browse All 4 View Live

Answer by Nicol Bolas for Lua, if statement idiom

If you really want to do this in the most compact way possible, you can create a function to do it. I generally only have it take one parameter per condition, but if you absolutely need one that...

View Article



Answer by Srdjan M. for Lua, if statement idiom

As pointed out by "Paul Kulchenko" in his last sentence, I ended up adding two idioms...local a = {}local b = {}local c,d = (a~=nil) and 1 or 0, (a~=nil) and 1 or 0 -- prints "1 1"local c,d = (a==nil)...

View Article

Answer by Paul Kulchenko for Lua, if statement idiom

Is there a way to print "0 0"?No, because and or expression always returns one result and the results you see are probably not for the reason you think they are.local c,d = (a~=nil) and 1,1 or 0,0 --...

View Article

Lua, if statement idiom

local a = {}local b = {}local c,d = (a~=nil) and 1,1 or 0,0 -- prints "1 1"local c,d = (a==nil) and 1,1 or 0,0 -- prints "false 1"print(c,d)I get why this happens. Is there a way to print "0 0"?

View Article
Browsing latest articles
Browse All 4 View Live




Latest Images