On Fri, Apr 21, 2017 at 09:05:15AM +0800, Ben Coman wrote:
> On Fri, Apr 21, 2017 at 12:31 AM, Nicolas Cellier
> <[email protected]> wrote:
> >
> > On the other hand, we have #keysAndValuesDo: which competes with
> > #withIndexDo: and is a bit more portable across dialects
> > (it's just that it turns the bloc parameters the other way around, [:index
> > :element | ])
> >
> > So maybe this should have been #keysAndValuesSelect: #keysAndValuesCollect:
> >
> > Reminder, keys does not mean Dictionary, in an IndexedCollection (or maybe a
> > SequenceableCollection) the keys are indices. Or the other way around, a
> > Dictionary is indexed by arbitrary keys (not just positive integers).
>
> Sounds like something I should know, but I'm not quite getting it.
> Could you provide an example?
Is this what you meant?
| results |
results := OrderedCollection new.
#('a' 'b' 'c' 'd') keysAndValuesDo:
[ :k :v | results add: { k. v. } ].
results
Cheers,
Alistair