squeak2.2 buglet in SequenceableCollection

Douglas McPherson djm at san.rr.com
Tue Nov 24 17:37:01 UTC 1998


I think I have come across a small possible bug in 2.2.

1) In SequenceableCollection>>asStringWithCr.

The cascade of cr in the false block below is incorrect since the elements
of the sequenceableCollection won't, in general, understand 'cr'.

'From Squeak 2.2 of Sept 23, 1998 on 24 November 1998 at 9:07:59 am'!

!SequenceableCollection methodsFor: 'converting'!
asStringWithCr
	"Convert to a string with returns between items.  Elements are
usually strings.
	 Useful for labels for PopUpMenus."
	| labelStream |
	labelStream _ WriteStream on: (String new: 200).
	self do: [:each |
		(each isKindOf: String)
			ifTrue: [labelStream nextPutAll: each; cr]
			ifFalse: [each printOn: labelStream; cr]].
	self size > 0 ifTrue: [labelStream skip: -1].
	^ labelStream contents! !

A possible simple solution:

!SequenceableCollection methodsFor: 'converting' stamp: 'djm 11/20/1998 05:44'!
asStringWithCr
	"Convert to a string with returns between items.  Elements are
usually strings.
	 Useful for labels for PopUpMenus."
	| labelStream |
	labelStream _ WriteStream on: (String new: 200).
	self do: [:each |
		(each isKindOf: String)
			ifTrue: [labelStream nextPutAll: each; cr]
			ifFalse: [each printOn: labelStream. labelStream cr]].
	self size > 0 ifTrue: [labelStream skip: -1].
	^ labelStream contents! !

Doug.





More information about the Squeak-dev mailing list