'
table' = global table with the name 'table'.
'
table' = your function argument for deleteLine() called 'table'.
The argument of
deleteLine() which receives a table is named '
table' and is local to this function.
That means while you're within your function,
table.remove() will try to call the
remove() function from '
table' and not from the global '
table'.
Remember that calling
table.remove() is the same as retrieving from the table 'table' the value for the key "
remove", which is then executed as a function:
table.remove() == table["remove"]()
So within your function you call
table.
remove(), but the table you receive as a function argument doesn't hold the
remove() function, because it is whatever table you fed
deleteLine() and that most probably won't coincidentally contain the remove() function of the global table, unless you specifically inserted that into it. :huh:/>/>
If you want to call the
remove() function from the
global '
table', then you either have to use another argument name than 'table', or you have to copy the global '
table' into another variable before you call your function
deleteLine().
For example:
function deleteLine( table, index )
-- some other ode
gTable.remove( table, 2 )
end
local gTable = table
local customTable = { "abc", "def", "xyz" }
deleteLine( customTable, 2 )
Disclaimer: Haven't tested the code yet.EDIT: Corrected an error in the code.