diff options
-rw-r--r-- | enum.c | 78 |
1 files changed, 40 insertions, 38 deletions
@@ -4455,36 +4455,35 @@ int_range_sum(VALUE beg, VALUE end, int excl, VALUE init) } /* - * call-seq: - * enum.sum(init=0) -> number - * enum.sum(init=0) {|e| expr } -> number - * - * Returns the sum of elements in an Enumerable. * - * If a block is given, the block is applied to each element - * before addition. * - * If <i>enum</i> is empty, it returns <i>init</i>. * - * For example: * - * { 1 => 10, 2 => 20 }.sum {|k, v| k * v } #=> 50 - * (1..10).sum #=> 55 - * (1..10).sum {|v| v * 2 } #=> 110 - * ('a'..'z').sum #=> TypeError * - * This method can be used for non-numeric objects by - * explicit <i>init</i> argument. * - * { 1 => 10, 2 => 20 }.sum([]) #=> [1, 10, 2, 20] - * "a\nb\nc".each_line.lazy.map(&:chomp).sum("") #=> "abc" * - * If the method is applied to an Integer range without a block, - * the sum is not done by iteration, but instead using Gauss's summation - * formula. * - * Enumerable#sum method may not respect method redefinition of "+" - * methods such as Integer#+, or "each" methods such as Range#each. */ static VALUE enum_sum(int argc, VALUE* argv, VALUE obj) @@ -4552,12 +4551,23 @@ uniq_iter(RB_BLOCK_CALL_FUNC_ARGLIST(i, hash)) /* * call-seq: - * enum.uniq -> new_ary - * enum.uniq { |item| ... } -> new_ary * - * Returns a new array by removing duplicate values in +self+. * - * See also Array#uniq. */ static VALUE @@ -4587,21 +4597,13 @@ compact_i(RB_BLOCK_CALL_FUNC_ARGLIST(i, ary)) /* * call-seq: - * enum.compact -> array - * - * Returns an array of all non-+nil+ elements from enumeration. * - * def with_nils - * yield 1 - * yield 2 - * yield nil - * yield 3 - * end * - * to_enum(:with_nils).compact - * # => [1, 2, 3] * - * See also Array#compact. */ static VALUE |