Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Lua - simple iterator assignment?

Tags:

iterator

lua

I'm new to Lua so please bear with this simple question :)

I'm simply trying to iterate over a table, and modify it's values. however, it seems I can't modify directly the "value" part?

code:

for id,value in pairs(some_table) do
    value = value * some_math_here
end

will i actually need to modify some_table[id] instead, or is there a more elegant way?

like image 478
J.C. Inacio Avatar asked Mar 22 '26 17:03

J.C. Inacio


1 Answers

You will actually need to modify

some_table[id]

instead. value does not actually represent some_table[id]

like image 96
Brandon Frohbieter Avatar answered Mar 26 '26 08:03

Brandon Frohbieter



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!