lua-users home
lua-l archive

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


In Programming in Lua, Third Edition:

Exercise 2.6: Assume the following code:
a = {};
a.a = a
1. What would be the value of a.a.a.a ? Is any a in that sequence somehow
different from the others?
2. Now, add the next line to the previous code:
a.a.a.a = 3
What would be the value of a.a.a.a now?

my reasoning is
1. a.a.a.a = ((a.a).a).a = (a.a).a = a.a = a
2. with the the previous reasoning, 'a' should be 3.
    but actually, 'a.a' equals 3 and 'a' is a table.
why?