[Newbies] Populate a new array

Bert Freudenberg bert at freudenbergs.de
Mon Mar 12 10:28:00 UTC 2007


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 -




More information about the Beginners mailing list