'[ENH]' repeat: 2

Mats Nygren nygren at sics.se
Thu Sep 7 15:24:47 UTC 2000


merlyn at stonehenge.com (Randal L. Schwartz) wrote:
> >>>>> "Mats" == Mats Nygren <nygren at sics.se> writes:
> 
> Mats> Hi,
> Mats> A sometimes useful method, second version
> 
> Mats> 	s := WriteStream on: (self class new: anInteger * self size).
> 
> I thought about this solution.  Not too be too pedantic,
> but shouldn't that be "self species" rather than "self class"?
> For the classes that implement #species, it would make a difference.

ok, now
  (1 to: 5) repeated: 3
works (although I probably would use "index - 1 \\ 5 + 1" instead, as in
atWrap: ).

/Mats

!SequenceableCollection methodsFor: 'copying' stamp: 'mn 9/7/2000 08:35'!
repeated: anInteger
	"Appends the specified number of copies of self"
	"'bar' repeated: 2"
	| s |
	s := WriteStream on: (self species new: anInteger * self size).
	anInteger timesRepeat: [ s nextPutAll: self ].
	^ s contents.! !





More information about the Squeak-dev mailing list