lua-users home
lua-l archive

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

Hi all,

using Lua 5.1, I'm trying to define a method in a table that has been returned by a previous method call, like this:

    function x:y("someObject"):f()
        -- ...

Unfortunately, this doesn't work: <name> or '...' expected near '"someObject"'

Alternatives that work are

    x:y("someObject").f = function(self)
        -- ...

or maybe

    local someObject = x:y("someObject")

    function someObject:f()
        -- ...

but these are also the only working variants that I have found, and was wondering if there is a way to write this closer to the former one-line variant?

Best regards,

Dipl.-Inf. Carsten Fuchs

Carsten Fuchs Software
Industriegebiet 3, c/o Rofu, 55768 Hoppstädten-Weiersbach, Germany
Internet: | E-Mail:

Cafu - the open-source game and graphics engine for multiplayer 3D action