[BUG] Set>>collect:

Bill Spight bspight at pacbell.net
Fri Feb 14 00:06:56 UTC 2003


All:

This afternoon I watched a Set appear where I wanted an IdentitySet. The
culprit seems to be here:

Set>>collect: aBlock 
 	"Evaluate aBlock with each of the receiver's  
 	elements as the argument.  
 	Collect the resulting values into a collection 
 	like the receiver. Answer  
 	the new collection."
 	| newSet |
 	newSet _ Set new: self size.    "Right here: Set"
 	array
 		do: [:each | each
 				ifNotNil: [newSet
 						add: (aBlock value: each)]].
 	^ newSet



Quick fix seems to work: Set -> Set, IdentitySet -> IdentitySet.

Set>>collect: aBlock 
 	"Evaluate aBlock with each of the receiver's  
 	elements as the argument.  
 	Collect the resulting values into a collection 
 	like the receiver. Answer  
 	the new collection."
 	| newSet |
 	newSet _ self species new: self size.     "Change: self species"
 	array
 		do: [:each | each
 				ifNotNil: [newSet
 						add: (aBlock value: each)]].
 	^ newSet



Best to all,

Bill



More information about the Squeak-dev mailing list