[squeak-dev] Collection>sum fails on empty collection

tim Rowledge tim at rowledge.org
Tue Jan 8 19:36:52 UTC 2019

#() sum -> errorEmptyCollection.

#sum uses #reduce: and I can see why #reduce might consider an empty collection an error - but I also see that #sum of an empty collection probably ought to be 0, at least in a lot of cases. And I'd note that using a simple #inject:into: - in the case of a million item Array, at least - took about 60% of the time of the current #sum.

Why did this come up? In an MVC Project I tested 
  PluggableFileList getFolderDialog openLabel: 'foo'
whilst seeing if PluggableFileList had any uses. It turns out that building a PluggableFileList in MVC doesn't work. Somewhere we end up trying to build a pluggablepanel with no children, which makes the logic in MVCToolBuilder>>setLayout:in: get upset. I don't care enough about making MVC stuff work to be willing to spend time on that.

tim Rowledge; tim at rowledge.org; http://www.rowledge.org/tim
Fractured Idiom:- RIGOR MORRIS - The cat is dead

More information about the Squeak-dev mailing list