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()
        -- ...
    end

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

Alternatives that work are

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

or maybe

    local someObject = x:y("someObject")

    function someObject:f()
        -- ...
    end

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,
Carsten



--
Dipl.-Inf. Carsten Fuchs

Carsten Fuchs Software
Industriegebiet 3, c/o Rofu, 55768 Hoppstädten-Weiersbach, Germany
Internet: http://www.cafu.de | E-Mail: info@cafu.de

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