April 30, 2018
6:37 p.m.
Hi - I hit a small bug in my lunch experiments with Willow where I wanted to sum up a collection of support hours. I was collect: in the hours worked and hadnât accounted for an empty collection. When I went to do it I was surprised there isnât a concept of #collect:ifNone: that mirrors something like at:ifAbsent: or the nicely readable collect:thenXxx: methods. Why is this? Iâm curious about style - and the elegance of my workaround : result ifEmpty: [ 0 ] ifNotEmpty:[ :r | r collect: [:I | i hours ]] which is ok, but seems a mouthful? Am I missing a trick? Tim Sent from my iPhone