






Hotspots: Admin Pages | Turn-in Site |
Current Links: Case Final Project Summer 2007
Sum2002 Midterm Review: Reading Code
Edit Sum2002 Midterm Review: Reading Code here.
What appears on the Transcript?
abcdefghijkl
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
changed.
- alan fay (emptyset@cc.gatech.edu)
Actually, running it gives
abcdefghi,jkl
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..
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?
- alan fay (emptyset@cc.gatech.edu)
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?
#('abc''def''ghi','jkl')
Got it?
Shaggz
Link to this Page