Hi all!
This issue is listed as a "newbie trap" on this page, search for "newbie
trap":
http://wiki.squeak.org/squeak/3644
...and there is another cool one just above, which goes like this:
"This one actually is borrowed from Leandro Caniglia. He
challenged me yesterday to figure out why the method SmallInteger>>gcd:
actually works. The challenge can also be expressed like this:
Evaluate this code below and figure out why n=5.
One could ask oneself if the assignment (m := n) is performed after or
before the evaluation of the expression?
If it is done before - then n should become 4 right? (2 + 2)
And if it is done after then it should become 6... (3 + 3)
Gurus: don't spoil it for the newbies ok? Let them chew on it for a
while... :-)"
| m n |
n := 2.
m := 3.
n := m + (m := n)
_______________________________________________
Pharo-project mailing list
[email protected]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project