So if i go print(i.." "..v) the i is 1 and the v is whatever is in the table, so why does it print out the v when i go print(table[i])
It might be a little clearer if we rewrite
for i,v in pairs(table) do print(table[i]) end
as
for index, value in pairs(table) do print(table[index]) end
The i
or index
here refers to the index in table table
of value v
or value
.
Basically, table[i] == v
returns true because i
is defined that way.