aboutsummaryrefslogtreecommitdiffstats
path: root/array.c
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-04-22 11:44:34 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-04-22 11:44:34 +0000
commitef6af0c9670a2b7ad14696990c82572cf41ca9aa (patch)
tree5b7d3bccc2686e8c62c138a0aea0dba998fb9622 /array.c
parentfac42e6c766a32734b055d0bfccb09ded14783d9 (diff)
downloadruby-ef6af0c9670a2b7ad14696990c82572cf41ca9aa.tar.gz
[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.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/array.c b/array.c
index 9f94a6d8dc..5a0d8aa0e5 100644
--- a/array.c
+++ b/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#+.
*
*/