lua-users home
lua-l archive

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

On Thu, Jan 27, 2011 at 12:13 PM, Axel Kittenberger <> wrote:
> any content of metatables? My guess that newbies are so freightened
> from metas is just exactly the __syntax.

Hm, I don't think newbies should worry themselves about metatables.
They are a subtle concept and the underscores are the least part.

Bear in mind that it _is_ common to put things into metatables;
there's a common OOP pattern that works like this:

-- define a class
A = {}
A.__index = A

function A:method() ... end

-- make an instance of the class
a = setmetatable({},A)

'index' will easily collide with a possible method name.

steve d.