Thursday 15 May 2014

make lua method that can directly change arguments -


How to create a method like

string.gsub (...) ?

I think that can change the argument in my function which I pass them to the function.

I know that string and number type go through the name in the variable variable (by calling the call value),

but when I call it s: gsub (...) I try to use such as s , I do not know how to change gsub (directly applied in string type variables) can change code> variable changes and gsub (.. .) affected by the method!

I would like to create a method inc (...) when I see it like ex: inc () (number var) 1 Growth! !!!

Let me help implement it ... I think the pre variable (example: Ex = 1) is numeric (not table)

  ex = 1 ex: Inc () print (ex) - ex == 2   

thanks you <.

s: gsub (...) does not s , except that when you do s = s: Gsub (...) . Try it:

  s = "Hello" print (s: gsuub ("[aoou]", "-")) print (s)   

In Lua, all logic values ​​are passed by. There is no way to change the value of a variable from within a function. (You can change the content of a table, but not the table itself.)

No comments:

Post a Comment