confusion about an exercise in programming lua 3rd
[
Date Prev][
Date Next][
Thread Prev][
Thread Next]
[
Date Index]
[
Thread Index]
- Subject: confusion about an exercise in programming lua 3rd
- From: Kang Hu <hukangustc@...>
- Date: 2014年11月25日 20:57:52 +0800
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?