[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: RE: Functions in Table constructors
- From: "Eric Ries" <eries@...>
- Date: Fri, 16 Nov 2001 13:43:13 -0800
Of course Steve is correct here. I did not notice that your second example
was "function func2()" instead of "func2 = function()"
Eric
> -----Original Message-----
> From: owner-lua-l@tecgraf.puc-rio.br
> [mailto:owner-lua-l@tecgraf.puc-rio.br]On Behalf Of Steve Dekorte
> Sent: Friday, November 16, 2001 1:33 PM
> To: Multiple recipients of list
> Subject: Re: Functions in Table constructors
>
>
>
> On Friday, November 16, 2001, at 01:25 PM, Matt Holmes wrote:
>
> > Is it possible to define a function inside a tables constructor?
> >
> > For instance:
> >
> > t = {
> > func1 = function(self, test)
> > DoStuff()
> > end
> >
>
> yes
>
>
> > function func2(self, test)
> > DoStuff()
> > end
> > }
>
> no
>
> >
> > And if I can define a function this way, can I invoke them as:
> > t:func1("1234")
> > t:func2("1234")
> >
>
> yes
>
> > or would I have to do
> > t.func1(t, "1234")
> > t.func2(t, "1234")
>
> this also works.
>
> Steve
>
>