Question - Projecting a collection onto a larger collection
Ingo Hohmann
ingo at 2b1.de
Fri Jun 20 18:00:18 UTC 2003
Hi Brent,
Brent Pinkney wrote:
<...>
> e.g. I want to map {Date. Time } to { Date. Date class. Time. Time class }
>
> I dimly remember seeing some mention of a project: method
>
> I am looking for Something of the flavour:
>
> {Date. Time } project: [ :nc :e | nc add: e; add: e class ].
You may be thinking about inject:into: , which is used like this:
{Date. Time} inject: {} into: [ :coll :each |
coll _ coll copyWith: each. coll copyWith: each class]
Which gives:
#(Date Date class Time Time class)
(The value given to inject: is the initial value of coll, and then the
last value of the block is always "injected" into coll .)
I hope that helped.
Ingo
More information about the Squeak-dev
mailing list
|