On 07 Jan 2016, at 14:08, Denis Kudriashov <dionisiydk@gmail.com> wrote:
2016-01-07 13:14 GMT+01:00 Max Leske <maxleske@gmail.com>: Very, very cool Sven (and Henrik!)!
And it even works with exotic objects: { 1@2. 2@3 } numbers sum ââ> (3@5)â
I really not understand how it helps with original problem. There was example with colors sum which was stop people to allow sum on empty collection. How extra message solve it?
(You should look at the code ;-) The example is confusing and not really relevant (because the points are not numbers). Basically, sending #numbers to a collection returns an object, called a 'collection operations' object (just a wrapper) that offers an interface to do more operations on the collection, with the additional assumption that it now contains (real) numbers. #(1 2 3) numbers sum => 6 #() numbers sum => 0 #(1 2 3) numbers product => 6 #() numbers product => 1 #(1 2 3) asSet magnitudes max #() asSet magnitudes maxIfEmpty: [ 100 ] But again, the code was just me thinking out loud, inspired by what Henrik did, I am totally not sure it is a really good idea. Sven