[squeak-dev] Re: #collect: on strings

Klaus D. Witzel klaus.witzel at cobss.com
Wed Jun 25 20:57:30 UTC 2008


On Wed, 25 Jun 2008 22:37:52 +0200, Damien Cassou wrote:

> On Wed, Jun 25, 2008 at 4:59 PM, Klaus D. Witzel
...
>>>> 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
>
> What does #coercedWith: mean? I would agree if it is something like:
> "try to make a collection of the same species as the parameter with
> the content of the receiver and if it is not possible, return the
> receiver"

Right. It would perhaps ask (argument #couldStore: anElement) and,  
ifFalse, return a #copyFrom:to: of its array (Array should be the default,  
IHMO). And if all pass then

  ^ argument species withAll: self

For sure this all could also be moved right into the #collect: method,  
might perform a bit faster. But anyways, things seem to have such price  
tag.

>




More information about the Squeak-dev mailing list