[Pharo-project] Issue 3761 in pharo: overlappingPairsCollect: fails on OrderedCollections

pharo at googlecode.com pharo at googlecode.com
Mon Feb 28 21:35:28 CET 2011

Comment #2 on issue 3761 by snoob... at yahoo.ie: overlappingPairsCollect:  
fails on OrderedCollections

Need to change #at:put: to rather be #add:.

The reason for this is explained in comment of OrderedCollection>>at:put:
"Put anObject at element index anInteger. at:put: cannot be used to append,  
front or back, to an ordered collection; it is used by a knowledgeable  
client to replace an element."

Change could be as given below...

overlappingPairsCollect: aBlock
	"Answer the result of evaluating aBlock with all of the overlapping pairs  
of my elements."
	| retval |
	retval := self species new: self size - 1.
	1 to: self size - 1
		do: [:i | retval add: (aBlock value: (self at: i) value: (self at: i +  
1)) ].

More information about the Pharo-project mailing list