lua-users home
lua-l archive

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


Maxime Petazzoni wrote:
> When a create an table and then make a copy of it :
> 
> local table = { }
> second = table
> 
> Does a change on table will be propagated to second?

'second' is not a copy. The variables 'table' and 'second' are both
refering to the same table. Which you can see:

  a = {}
  b = a
  c = b
  print(a,b,c)

> local table = { }
> 
> function table.test ()
>  print("Mooh !")
> end
>
> Does it creates a function test inside the table 'table' ?

Yes, that is exactly equivalent to:

  table.test = function() print("Mooh !") end

Which is exactly equivalent to:

  table["test"] = function() print("Mooh !") end