Programming-Idioms

History of Idiom 54 > diff from v22 to v23

Edit summary for version 23 :
New Ruby implementation by user [programming-idioms.org]

Version 22

2017-03-26, 22:00:59

Version 23

2017-03-27, 19:20:06

Idiom #54 Compute sum of integers

Calculate the sum s of integer list x.

Idiom #54 Compute sum of integers

Calculate the sum s of integer list x.

Code
s = x.reduce(:+)
Comments bubble
This was idiomatic before Ruby 2.4
Doc URL
http://ruby-doc.org/core-2.2.3/Enumerable.html#method-i-reduce