Le 16 mars 2015 11:59, "Nicolai Hess" <nicolaih...@web.de> a écrit :
>
>
> 2015-03-14 11:55 GMT+01:00 Sean P. DeNigris <s...@clipperadams.com>:
>>
>> Marcus Denker-4 wrote
>> > which version do we pick? We should pick one, rename the callers
>>
>> As someone mentioned earlier in the thread, #doWithIndex: has the
advantage
>> of mirroring the argument order (although this still should be
documented),
>> and it's the one most people are probably most familiar with, so IMHO it
>> makes sense to standardize on that.
>
>
> I like withIndexDo: because code like
>
> aCollection withIndexDo: aBlock
> reads like
> "a collection with index"  do
>

I like things ending with do: as they are easy to spot. And you know that
is coming next is a block most of the time.

Not so with doWithIndex:

e.g.

someObject mongoDo: [ ... ].

reads better than

someObject doWithMongo: [ ].

especially when there are things like

mongoDo:
mongoCachedCollectionsDo:
aggregateDo:

and so on.

This is the same story with

... readStreamDo: [  ]

withIndexDo: obeys the principle of least astonishment to me.

Phil

>
>
>
>>
>>
>>
>>
>> -----
>> Cheers,
>> Sean
>> --
>> View this message in context:
http://forum.world.st/when-iterating-over-a-collection-how-to-determine-the-current-objects-index-tp4810920p4811848.html
>> Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.
>>
>

Reply via email to