[Newbies] Populate a new array.
blake at kingdomrpg.com
Sun Mar 11 09:40:45 UTC 2007
Here's another one:
I've created a method that returns an array of its own class:
| a |
a := Array new: aQuantity.
do: [:i | a at: i put: self class new].
but, for a while, I was trying to make this a single line:
^ (Array new: aQuantity) do: [:item | item := stuff ]
This doesn't work (I think) because "do" passes in a value rather than a
reference. I didn't see how it could be done with withIndexDo: either.
Wondering if I'm missing something.
Also, observing that "at:" is actually implemented in Object, which
More information about the Beginners