[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: How to write function x:y():f() ... end ?
- From: Carsten Fuchs <carsten.fuchs@...>
- Date: Tue, 26 Feb 2013 11:42:00 +0100
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