[Pharo-users] Why do #select:thenXxx methods not return their result

Tim Mackinnon tim at testit.works
Thu Jun 7 19:17:04 EDT 2018


You are correct Peter - I jumped the gun, as it was #select:thenDo: where I hit the problem - and yes it doesn’t make sense to answer a result from Do.

I do kind of miss the concept of: #select:thenDo:ifNone: as well as #select:thenCollect:ifNone: but some bracketing sorts it out, and I guess where do you stop.

Tim

> On 7 Jun 2018, at 13:25, Peter Uhnák <i.uhnak at gmail.com> wrote:
> 
> How do you mean?
> 
> (1 to: 10) select: #odd thenCollect: [ :x | x ** 2 ] "-> #(1 9 25 49 81)"
> 
> It wouldn't make sense otherwise to have the collect method if it wouldn't return anything.
> 
> Peter
> 
> On Thu, Jun 7, 2018 at 2:20 PM, Tim Mackinnon <tim at testit.works <mailto:tim at testit.works>> wrote:
> Hi - are the methods like #select:thenCollect: frowned upon? 
> 
> They seem quite readable , however in using them I’ve noticed that unlike the core methods they done return the result of evaluation (they are missing a ^). This is a shame, but possibly an oversight?
> 
> Tim
> 
> Sent from my iPhone
> 
> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.pharo.org/pipermail/pharo-users_lists.pharo.org/attachments/20180608/1e74d98f/attachment.html>


More information about the Pharo-users mailing list