5 ms·
Sorry but this is 12 lines of Lua code, what is the value proposition/use case here? I'm legitimately curious.
by SSchick 2y ago
Sorry but this is 12 lines of Lua code, what is the value proposition/use case here? I'm legitimately curious.
- alurm 2y agoHonestly, not much. I found it nice how it's possible to emulate switches in Lua with so little code, without the result looking too ugly. You may find this pattern useful. That's it. The catch is that, unlike with normal switches or with a series of "if"s, there's a whole bunch of indirection added via functions, so it's not very efficient. Perhaps LuaJIT can inline these functions, but I haven't tested it.