lua-users home
lua-l archive

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

>>Is there any way to avoid the first or second mention of test[1]?
The function will always use the first parameter as its object, so I could
also write:

I think the syntax of what you trying to do should be:

test[1].do_something(test[1])  -- calling with self as 1st parameter

is equivalent to: (not : instead of .)

test[1]:do_something()  -- a call

then you have an "automatic" variable created called "self". (section 4.5.9
in manual).

function test[1]:do_something()
    self.var = 12345

I dont much care for these automatic variables but thats a different story.
The above is equivalent to:

function test[1].do_something(self)
    self.var = 12345

>> test[2].do_something(test[1])

I assume this is a typo.