Quantcast
Channel: Pragmatic Forums | Posts in topic 'IO day 3 mystery: the Builder example'
Viewing all articles
Browse latest Browse all 34

IO day 3 mystery: the Builder example posted by Brooks Boyd @ Wed, 14 Dec 2011 16:32:56 +0000

$
0
0

Thread necromancy here, but I think I have the answer: Because you have one extra line after your doMessage() call, the program execution enters the forward method, progresses to the first argument, and calls that argument, which is the forward method again. Because of that, the program execution quickly gets to the deepest level of the builder tree first, though there’s still hanging writeln("CONTENT") lines waiting to be executed after doMessage() completes. So, the deepest level (Sequences) finish their execution by printing their content, and return to the next level. Because you have nothing explicitly returned, the result of the last message (println) is returned, which is nil. The next level up prints that as content, leading to two stacked “CONTENT” lines. If you were to nest your builder command even deeper (b ul( li( a("Io")), li( a("Lua"))), you’d see three stacked “CONTENT” lines.


Viewing all articles
Browse latest Browse all 34

Latest Images

Trending Articles





Latest Images