зеркало из https://github.com/github/ruby.git
Remove redundant each from `sum` example (#2190) [ci skip]
It used to be `Enumerator#sum`, now it's range of string which calls `Enumerable#sum` and causes TypeError.
This commit is contained in:
Родитель
7624154595
Коммит
efd37f8fc3
2
enum.c
2
enum.c
|
@ -4017,7 +4017,7 @@ int_range_sum(VALUE beg, VALUE end, int excl, VALUE init)
|
||||||
* { 1 => 10, 2 => 20 }.sum {|k, v| k * v } #=> 50
|
* { 1 => 10, 2 => 20 }.sum {|k, v| k * v } #=> 50
|
||||||
* (1..10).sum #=> 55
|
* (1..10).sum #=> 55
|
||||||
* (1..10).sum {|v| v * 2 } #=> 110
|
* (1..10).sum {|v| v * 2 } #=> 110
|
||||||
* [Object.new].each.sum #=> TypeError
|
* ('a'..'z').sum #=> TypeError
|
||||||
*
|
*
|
||||||
* This method can be used for non-numeric objects by
|
* This method can be used for non-numeric objects by
|
||||||
* explicit <i>init</i> argument.
|
* explicit <i>init</i> argument.
|
||||||
|
|
Загрузка…
Ссылка в новой задаче