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 ArticleAnswer 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 ArticleAnswer 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 ArticleLua, 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