|
Populate a new array.: msg#00085lang.smalltalk.squeak.beginners
Here's another one: I've created a method that returns an array of its own class: anArray: aQuantity | a | a := Array new: aQuantity. a size do: [:i | a at: i put: self class new]. ^ a 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 seems...odd!
|
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | Re: Sortable?, Blake |
|---|---|
| Next by Date: | Re: Populate a new array., Bert Freudenberg |
| Previous by Thread: | Sortable?, Blake |
| Next by Thread: | Re: Populate a new array., Bert Freudenberg |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |