diff options
author | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-04-22 11:44:34 +0000 |
---|---|---|
committer | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-04-22 11:44:34 +0000 |
commit | ef6af0c9670a2b7ad14696990c82572cf41ca9aa (patch) | |
tree | 5b7d3bccc2686e8c62c138a0aea0dba998fb9622 /array.c | |
parent | fac42e6c766a32734b055d0bfccb09ded14783d9 (diff) |
[DOC] Arrah#sum with non-numeric objects.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54705 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'array.c')
-rw-r--r-- | array.c | 14 |
1 files changed, 13 insertions, 1 deletions
@@ -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#+. * */ |