On 01 Dec 2015, at 15:11, Tudor Girba <tudor@tudorgirba.com> wrote:
Hi,
On Dec 1, 2015, at 12:52 PM, Sven Van Caekenberghe <sven@stfx.eu> wrote:
On 01 Dec 2015, at 12:45, Stephan Eggermont <stephan@stack.nl> wrote:
On 01-12-15 11:46, Sven Van Caekenberghe wrote:
The basic question for me is, what should
#() sum
return. Right now, it is an error, I would very much like that for this common case the result would be 0. There is a lot of power (easy of use) in a unary selector, we should not destroy that with semantics that force a test before using it.
I like the error, it aligns with most of our collection protocol.
I hate the error, a lot ;-)
It shows the need for #sum:ifEmpty: though
Yes, as long as #() sum == 0
That wonât work :).
But wouldnât it be nice to have #sum:ifEmpty:? I think that this is a nice way to describe summing. Otherwise I have to do ifEmpty: [ something ] ifNotEmpty: [ :col | col sum: ⦠] Cheers. Uko
I want the simplest case to be simple, having a non-0 default is a special case IMHO
That is why you have sumNumbers:. We could also add Collection>>sumNumbers.
We had this discussion at length before Pharo 4, and this is when we agreed to add sumNumbers: and let sum: be generic (like the name says it should be) and not assume that it should work with Numbers.
Cheers, Doru
Stephan
-- www.tudorgirba.com
"Speaking louder won't make the point worthier."