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:
parent
fac42e6c76
commit
ef6af0c967
1 changed files with 13 additions and 1 deletions
14
array.c
14
array.c
|
@ -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#+.
|
||||
*
|
||||
*/
|
||||
|
|
Loading…
Reference in a new issue