roassal3 at:put "why"

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

roassal3 at:put "why"

Squeak - Dev mailing list
Hi folks.

Here is the "why" of the failure....
OrderedCollection >> at: anInteger put: anObject
"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."

| index |
1 <= anInteger ifFalse: [ self errorNoSuchElement ].
(index := anInteger + firstIndex - 1) <= lastIndex ifFalse: [ self errorNoSuchElement ].
^array at: index put: anObject
At this point, the size of the collection is zero.
I will see if I can finagle this at the OC creation...

x := self species
new: 0
streamContents: [ :stream | self do: [ :each |
i := i +1.
stream nextPutAll: (aBlock value: each).
self break.
]].
That '0' is probably the problem.

cheers.