logo       

Re: Populate a new array: msg#00092

lang.smalltalk.squeak.beginners

Subject: Re: Populate a new array


On Mar 12, 2007, at 1:29 , Jerome Peace wrote:

Populate a new array.

On Mar 11, 2007, at 10:40 , Blake wrote:


Wondering if I'm missing something.

Bert replied:

^(1 to: aQuantity) collect: [:i | stuff]

or alternately can be added:

^Array new: aQuantity withAll: stuff

Not quite - this will put the same object into each slot. Imagine "stuff" being "i squared".

- Bert -


<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise