my main takeaway from Balatro's giant if statement is learning that Lua apparently doesn't have a switch equivalent

enthusiast enthusiast
offsite reposts: @nex3-reposts
clips & pics: @nex3-moments
Cohost utilities:
header photo by me
my main takeaway from Balatro's giant if statement is learning that Lua apparently doesn't have a switch equivalent
that was mine too. I don’t mind a giant table of conditions in code, but the way each one was an if…end, with no way for the language to warn you if you missed a case, that would make me nervous.
in this case because each condition was just a string I don't think you'd have had exhaustiveness checking, but you wouldn't have had to write joker.name == every single time
lua's prolly the "most constrained by parser design" language outside of esolangs and rly rly old PLs
yeah but that starts to get more syntactically complicated than a plain if statement which kind of defeats the purpose in this case
well. i mean. i rolled one for a 5-deep if equivalent over in tabletop simulator. its ugly but its fast.
Same deal as Python, where the official advice is "just use a set of if/elseif statements"
Lua is, at heart, a fundamental compromise between "it needs to be easy to use like a scripting language" and "the parser/interpreter has to run in real time on some very stupid computers"