[squeak-dev] Re: #collect: on strings
Klaus D. Witzel
klaus.witzel at cobss.com
Wed Jun 25 14:59:50 UTC 2008
On Wed, 25 Jun 2008 16:48:17 +0200, Damien Cassou wrote:
> On Wed, Jun 25, 2008 at 4:43 PM, Klaus D. Witzel
> <klaus.witzel at cobss.com> wrote:
>> On Wed, 25 Jun 2008 10:46:49 +0200, Damien Cassou wrote:
>>
>>> On Wed, Jun 25, 2008 at 9:39 AM, cdrick wrote:
>>>>
>>>> (Array withAll: 'something') collect: [ :letter | letter isVowel ].
>>>> #(false true false true false false true false false)
>>>
>>> I did that
>>>
>>> 'something' asArray collect: [ :letter | letter isVowel ].
>>>
>>> do get the desired behavior. However, it is not intuitive to me.
>>
>> I agree, in some cases I want to tell #collect: what #species to use
>> (OT:
>> and inspired by the LambdaMessageSend package, I have made a snippet
>> which
>> does feed #species into otherwise unchanged #collect:).
>>
>> But what do *you* expect to happen with your original expression, mind
>> to
>> share?
>
> A collection of boleans.
Well, let's look at #collect: it has a block as argument. Because of this
object orientedness, the implementor of #collect: cannot know what sort of
values the block will return in the future, no?
How about this, let #collect: always collect into anOrderedCollection,
then it can eventually
^ anOrderedCollection coercedWith: self
>
More information about the Squeak-dev
mailing list
|