View this PageEdit this Page (locked)Attachments to this PageHistory of this PageHomeRecent ChangesSearch the SwikiHelp Guide
Hotspots: Admin Pages | Turn-in Site |
Current Links: Cases Final Project Summer 2007

Courtland Goodson - Discussion 4

anArray aString
anArray := #('abc' 'def' 'ghi' 'jkl').
aString := ''.
anArray do: [:each |aString := aString, each.].
Transcript show: aString.

1. What appears on the Transcript ? abcdefghijkl

2. How many times did the do: loop get executed? The loop gets executed 4 times.


Note: if they put a comma in, like the sample question has, then the comma gets printed and the loop gets execute 5 times.


i test
i := 1.
test := (i 10).
[test] whileTrue: [Transcript show: 'hello'.i := i + 1.].

3. How many times does hello get printed in this example? The loop is an infinite loop. Therefore, hello prints continuously.

Link to this Page