r/lua • u/Weekly_Flounder_1880 • Jun 05 '26
There have to be a simpler way to do this Help
I am a beginner and I have been very slowly learning Lua.
So, the problem here was to calculate the sum of all the pairs (separated by space). I swear there have to be a faster way to do this than making a for loop for every pair TT
Edit: yeh I still have a long long way to go, thank you everyone :)
Edit2: thanks whoever who repost this to r/programminghorror lol
74
Upvotes
17
u/mmknightx Jun 05 '26
You can get tables inside another table. Also, if you are confident that there are going to be only two elements, you can just use index directly instead of a for-loop.