1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* enum.c (enum_inject): updated documentation. a patch from Keita

Yamaguchi <keita.yamaguchi@gmail.com> in [ruby-dev:32686].

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14556 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
matz 2007-12-23 20:35:12 +00:00
parent 19cf57f21c
commit 9bfdc4e736
2 changed files with 8 additions and 3 deletions

View file

@ -1,3 +1,8 @@
Mon Dec 24 05:32:22 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
* enum.c (enum_inject): updated documentation. a patch from Keita
Yamaguchi <keita.yamaguchi@gmail.com> in [ruby-dev:32686].
Mon Dec 24 05:13:04 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
* string.c (tr_trans): should associate new encoding if modified.

6
enum.c
View file

@ -370,12 +370,12 @@ inject_op_i(VALUE i, VALUE p)
/*
* call-seq:
* enum.inject(sym, initial) => obj
* enum.inject(initial, sym) => obj
* enum.inject(sym) => obj
* enum.inject(initial) {| memo, obj | block } => obj
* enum.inject {| memo, obj | block } => obj
*
* enum.reduce(sym, initial) => obj
* enum.reduce(initial, sym) => obj
* enum.reduce(sym) => obj
* enum.reduce(initial) {| memo, obj | block } => obj
* enum.reduce {| memo, obj | block } => obj
@ -403,7 +403,7 @@ inject_op_i(VALUE i, VALUE p)
* # Same using a block and inject
* (5..10).inject {|sum, n| sum + n } #=> 45
* # Multiply some numbers
* (5..10).reduce(:*, 1) #=> 151200
* (5..10).reduce(1, :*) #=> 151200
* # Same using a block
* (5..10).inject(1) {|product, n| product * n } #=> 151200
* # find the longest word