Function/variable scope (pass by value or reference?)

You guessed right, table variables are passed by reference. Citing Lua 5.1 Reference Manual:

There are eight basic types in Lua: nil, boolean, number, string, function, userdata, thread, and table.
….

Tables, functions, threads, and (full) userdata values are objects: variables do not actually contain these values, only references to them. Assignment, parameter passing, and function returns always manipulate references to such values; these operations do not imply any kind of copy.

So nil, booleans, numbers and strings are passed by value. This exactly explains the behavior you observe.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)