lua-users home
lua-l archive

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


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Terisquas Brothers wrote:
> 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 
> 

When something is a member of a table, you need to say "foo = value".
This is why the first one doesn't work. Try this if you want a more
function-y syntax:

tab = {}
function tab.b()
  echo "hi!";
end;
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFFoojNmhCgVPlWJY8RAmHRAJ9Rpa2wERy47t1TOf2fXtgkSRQx1QCgpEf0
BFA6aleXwwRf2dznijLppYM=
=4VrO
-----END PGP SIGNATURE-----