J.C. Inacio
J.C. Inacio

Reputation: 4472

Lua - simple iterator assignment?

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?

Upvotes: 3

Views: 203

Answers (1)

Brandon Frohbieter
Brandon Frohbieter

Reputation: 18139

You will actually need to modify

some_table[id]

instead. value does not actually represent some_table[id]

Upvotes: 6

Related Questions