1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

[DOC] Arrah#sum with non-numeric objects.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54705 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
akr 2016-04-22 11:44:34 +00:00
parent fac42e6c76
commit ef6af0c967

14
array.c
View file

@ -5674,7 +5674,19 @@ rb_ary_dig(int argc, VALUE *argv, VALUE self)
*
* mean = ary.sum(0.0) / ary.length
*
* This method may not respect method redefinition of "+" methods
* This method can be used for non-numeric objects by
* explicit <i>init</i> argument.
*
* ["a", "b", "c"].sum("") #=> "abc"
* [[1], [[2]], [3]].sum([]) #=> [1, [2], 3]
*
* However, Array#join and Array#flatten is faster than Array#sum.
*
* ["a", "b", "c"].join #=> "abc"
* [[1], [[2]], [3]].flatten(1) #=> [1, [2], 3]
*
*
* Array#sum method may not respect method redefinition of "+" methods
* such as Fixnum#+.
*
*/