lua-users home
lua-l archive

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


In MockJSonParser:new, instance refers to a global variable rather
than a local variable. If Product:new similarly uses a variable called
instance in the global sense (remember that all variables are global
by default, and need to be explicity declared local), then after
Product:new has been called to create the last item for the list, the
global "instance" will refer to that product, and the "return
instance" line of MockJSonParser:new will return that global.

On Wed, Apr 1, 2009 at 7:59 PM, Joao Eduardo Hornburg
<joao.hornburg@gmail.com> wrote:
> Hi,
> I'm trying to use OO in Lua. I wrote the following code:
> ...
> Can anyone tell me what I'm doing wrong?