79659787

Date: 2025-06-10 04:36:56
Score: 1
Natty:
Report link

res is defined as a local variable inside function subsets, so it only exists inside that function. When the function exits, the variable is destroyed. When you try and access res outside of the function, it doesn't exist, so Lua creates a new empty table for you. That is the problem with languages where you don't have to define variables before you use them. You get these weird run time errors that a robust language would detect at compile time. You need to either define res as a global variable, or define it inside the calling function and pass it to subsets.

Reasons:
  • Long answer (-0.5):
  • No code block (0.5):
  • Single line (0.5):
  • Low reputation (0.5):
Posted by: Ashley West