On Wed, Dec 2, 2015 at 12:38 AM, Tudor Girba <tudor@tudorgirba.com> wrote:
Hi,
On Dec 1, 2015, at 5:13 PM, Max Leske <maxleske@gmail.com> wrote:
@Doru Youâre missing the point: #anyOne *fails* for empty collections.
I am not missing the point at all. I am saying that if you want sum: to be generic, it cannot assume a specific Zero object.
And sum: should be generic because of its name.
I am missing understanding the other use cases. Can you describe further the generic nature of #sum & #sum: ? I would have thought by default they only applied to numbers. cheers -ben
On 01 Dec 2015, at 15:31, Esteban A. Maringolo <emaringolo@gmail.com> wrote:
I don't want to be heretic (or too orthodox), but why not to delegate this behavior to other class (an iterator maybe?).
It's too tempting adding these convenience methods to Collection and/or subclasses, but anything that requires an explicit protocol of its elements is wrong, IMO.
something like aCollection arithmetic sum: [...] or.... aCollection arithmetic avg.
Interesting thought!
+100
Doru
My two cents for this.
Regards!
Esteban A. Maringolo
-- www.tudorgirba.com
"Every thing has its own flow."