lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

Theodor-Iulian Ciobanu wrote:
1) I have a variable whose contents I would like it to be
modified by a function (would bee foo(&var) in C, with foo
declared as foo(var_type*)). Can I do this in lua?

The most common way to do it in Lua is to make foo return the modified values, e.g.:
    var1, var2 = foo (var1, var2)

(Also, if  var is a table then its contents can be modified inside foo).

2) str[n] is not the n-th character of str (when str is of course
a string). Would adding this to the language not be faster than
string.sub(str,n,n) or would it stray the lua way? (or is there a
better way of getting the n-th character from a string that I'm
missed in the ref manual?

See this thread: