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

Sum2002 Midterm Review: Reading Code

Edit Sum2002 Midterm Review: Reading Code here.

What appears on the Transcript?


How many times did the body of the do: loop get executed?

four times.

How many times does hello get printed in this example?

i think it's an infinite loop. test is assigned true, and cannot

Actually, running it gives
and it runs 5 times.
anArray := #('abc' 'def' 'ghi','jkl')

So apparently, squeak seperates arrays wrt qoutes (') first, then to spaces.

Some examples:
 #(abcdefghi,jkl) : one element 
 #(abcd fghi,jkl) : two elements
 #('abcdefghi,jkl') : one element
 #('ab' cd) : two elements
 #(ab'c'd)   : 3 elements

And so on..

Matt Alexander

try out the first two. Shaggz

but there's where i get tripped up. if the (') acts as a delimeter
within the array, then how is the token (abc) or the token (,)
considered a string object? the block executes as if the token was
assumed to be a string. what's really going on here?

First of all, look at the class of #,. Secondly, there is no token abc in the array, but rather something of the form 'abc'. They're similiar sorts of objects, but not the same. also look at,
 #('abc'def'ghi','jkl') #def?

Got it?

Link to this Page