No subject

reic0024 at d.umn.edu reic0024 at d.umn.edu
Tue May 29 22:25:58 UTC 2001


Hello everyone,

Short question: Does Smalltalk have a way to break out of a block like "break" 
does in C?

Long question: I'm reading in/parsing some not-always-nicely formed data files 
(as a part of my undergrad research at the NRRI 
[http://www.nrri.umn.edu/cwe/]).  Below is a block of code to handle some of 
these little uglys that pop up now and then in the datasets.

"ditch anything we don't need, and put in things like elevation and pipeup into 
params"
contents do: [ :coll |
	1 to: (coll size) do: [ :i |
		((coll at: i) beginsWith: 'ice:') ifTrue: [
			coll at: i put: (((coll at: i) findTokens: 'ice:')
				first) ].
		((coll at: i) beginsWith: ':ELEVATION:') ifTrue: [
			coll removeAt: i.
			params at: #elevation put: (((coll at: i) 
				findTokens: ':ELEVATION:') first) ].
		((coll at: i) beginsWith: ':PIPEUP:') ifTrue: [
			coll removeAt: i.
			params at: #pipeup put: (((coll at: i) 
				findTokens: ':PIPEUP:') first) ]]].

(contents is a Dictionary filled with strings associated with 
OrderedCollections)

Not the nicest looking code, I know. :P  Let's say that a value 
with ":ELEVATION:" is found, and the element at i is removed.  Of course, it 
runs into a problem accessing this when it looks for ":PIPEUP:".  In C, 
in ":ELEVATION:"'s ifTrue block, we'd just say break; to skip the rest of the 
stuff in the block.  I know I could add some silly variable and another ifTrue, 
but I am (always) looking for the better way to do things...

regards and thanks in advance!
Aaron





More information about the Squeak-dev mailing list