Simple assignment of an iterator?

I am new to Lua, so please accept this simple question :)

I am just trying to iterate through a table and change its values. however, it seems I can’t directly change the “value” part?

the code:

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

Do I really need to change some_table [id], or is there a more elegant way?

+3
source share
1 answer

You really need to change

some_table[id]

instead of this. the value does not actually represent some_table [id]

+6
source

Source: https://habr.com/ru/post/1796451/


All Articles