lua-users home
lua-l archive

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



It's just a matter of syntax sugar; "function b()" sugar is not applied within table constructors. Without sugar, you would need to write name= function() ... for _any_ functions.

Lua has this sort of things, since the language implementation is intended to be minimal, and straightforward. Observe that the following is also perfectly valid:

tab={ function() echo "hi!" end }

That places tab[1] as a function.

NB. You don't need the ;'s, coming from Perl?  ;)

-asko


Terisquas Brothers kirjoitti 1.1.2007 kello 14.45:


a fast one: I'm trying to do this:

tab={

function b()
  echo "hi!";
end;

};


but it fails. However

tab={

b=function()
  echo "hi!";
end;

};

works. Is this the intended way to work? I fail to see
any reason to disallow the first one




Happy new year! :)
Kak

Send instant messages to your online friends http:// uk.messenger.yahoo.com