mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* enum.c: Clean up wording in Enumerable documentation. Patch by b t.
[Ruby 1.9 - Bug #5411 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33416 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
9edfa89744
commit
e2974b1a4b
2 changed files with 20 additions and 19 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
Thu Oct 6 09:56:30 2011 Eric Hodel <drbrain@segment7.net>
|
||||||
|
|
||||||
|
* enum.c: Clean up wording in Enumerable documentation. Patch by b t.
|
||||||
|
[Ruby 1.9 - Bug #5411
|
||||||
|
|
||||||
Thu Oct 6 09:17:18 2011 Eric Hodel <drbrain@segment7.net>
|
Thu Oct 6 09:17:18 2011 Eric Hodel <drbrain@segment7.net>
|
||||||
|
|
||||||
* time.c (Init_Time): Remove editorial comments from Time
|
* time.c (Init_Time): Remove editorial comments from Time
|
||||||
|
|
34
enum.c
34
enum.c
|
@ -129,11 +129,11 @@ count_all_i(VALUE i, VALUE memop, int argc, VALUE *argv)
|
||||||
* enum.count(item) -> int
|
* enum.count(item) -> int
|
||||||
* enum.count {| obj | block } -> int
|
* enum.count {| obj | block } -> int
|
||||||
*
|
*
|
||||||
* Returns the number of items in <i>enum</i>, where #size is called
|
* Returns the number of items in <i>enum</i> if it responds to a #size call,
|
||||||
* if it responds to it, otherwise the items are counted through
|
* otherwise the items are counted through enumeration. If an argument is
|
||||||
* enumeration. If an argument is given, counts the number of items
|
* given the number of items in <i>enum</i> that are equal to <i>item</i> are
|
||||||
* in <i>enum</i>, for which equals to <i>item</i>. If a block is
|
* counted. If a block is given, it counts the number of elements yielding a
|
||||||
* given, counts the number of elements yielding a true value.
|
* true value.
|
||||||
*
|
*
|
||||||
* ary = [1, 2, 4, 2]
|
* ary = [1, 2, 4, 2]
|
||||||
* ary.count #=> 4
|
* ary.count #=> 4
|
||||||
|
@ -539,10 +539,9 @@ inject_op_i(VALUE i, VALUE p, int argc, VALUE *argv)
|
||||||
* return value for the method.
|
* return value for the method.
|
||||||
*
|
*
|
||||||
* If you do not explicitly specify an <i>initial</i> value for <i>memo</i>,
|
* If you do not explicitly specify an <i>initial</i> value for <i>memo</i>,
|
||||||
* then uses the first element of collection is used as the initial value
|
* then the first element of collection is used as the initial value
|
||||||
* of <i>memo</i>.
|
* of <i>memo</i>.
|
||||||
*
|
*
|
||||||
* Examples:
|
|
||||||
*
|
*
|
||||||
* # Sum some numbers
|
* # Sum some numbers
|
||||||
* (5..10).reduce(:+) #=> 45
|
* (5..10).reduce(:+) #=> 45
|
||||||
|
@ -837,7 +836,7 @@ sort_by_cmp(const void *ap, const void *bp, void *data)
|
||||||
* The current implementation of <code>sort_by</code> generates an
|
* The current implementation of <code>sort_by</code> generates an
|
||||||
* array of tuples containing the original collection element and the
|
* array of tuples containing the original collection element and the
|
||||||
* mapped value. This makes <code>sort_by</code> fairly expensive when
|
* mapped value. This makes <code>sort_by</code> fairly expensive when
|
||||||
* the keysets are simple
|
* the keysets are simple.
|
||||||
*
|
*
|
||||||
* require 'benchmark'
|
* require 'benchmark'
|
||||||
*
|
*
|
||||||
|
@ -970,9 +969,9 @@ DEFINE_ENUMFUNCS(all)
|
||||||
* Passes each element of the collection to the given block. The method
|
* Passes each element of the collection to the given block. The method
|
||||||
* returns <code>true</code> if the block never returns
|
* returns <code>true</code> if the block never returns
|
||||||
* <code>false</code> or <code>nil</code>. If the block is not given,
|
* <code>false</code> or <code>nil</code>. If the block is not given,
|
||||||
* Ruby adds an implicit block of <code>{|obj| obj}</code> (that is
|
* Ruby adds an implicit block of <code>{ |obj| obj }</code> which will
|
||||||
* <code>all?</code> will return <code>true</code> only if none of the
|
* cause #all? to return +true+ when none of the collection members are
|
||||||
* collection members are <code>false</code> or <code>nil</code>.)
|
* +false+ or +nil+.
|
||||||
*
|
*
|
||||||
* %w{ant bear cat}.all? {|word| word.length >= 3} #=> true
|
* %w{ant bear cat}.all? {|word| word.length >= 3} #=> true
|
||||||
* %w{ant bear cat}.all? {|word| word.length >= 4} #=> false
|
* %w{ant bear cat}.all? {|word| word.length >= 4} #=> false
|
||||||
|
@ -1005,10 +1004,9 @@ DEFINE_ENUMFUNCS(any)
|
||||||
* Passes each element of the collection to the given block. The method
|
* Passes each element of the collection to the given block. The method
|
||||||
* returns <code>true</code> if the block ever returns a value other
|
* returns <code>true</code> if the block ever returns a value other
|
||||||
* than <code>false</code> or <code>nil</code>. If the block is not
|
* than <code>false</code> or <code>nil</code>. If the block is not
|
||||||
* given, Ruby adds an implicit block of <code>{|obj| obj}</code> (that
|
* given, Ruby adds an implicit block of <code>{ |obj| obj }</code> that
|
||||||
* is <code>any?</code> will return <code>true</code> if at least one
|
* will cause #any? to return +true+ if at least one of the collection
|
||||||
* of the collection members is not <code>false</code> or
|
* members is not +false+ or +nil+.
|
||||||
* <code>nil</code>.
|
|
||||||
*
|
*
|
||||||
* %w{ant bear cat}.any? {|word| word.length >= 3} #=> true
|
* %w{ant bear cat}.any? {|word| word.length >= 3} #=> true
|
||||||
* %w{ant bear cat}.any? {|word| word.length >= 4} #=> true
|
* %w{ant bear cat}.any? {|word| word.length >= 4} #=> true
|
||||||
|
@ -1552,8 +1550,8 @@ minmax_by_i(VALUE i, VALUE _memo, int argc, VALUE *argv)
|
||||||
* enum.minmax_by {|obj| block } -> [min, max]
|
* enum.minmax_by {|obj| block } -> [min, max]
|
||||||
* enum.minmax_by -> an_enumerator
|
* enum.minmax_by -> an_enumerator
|
||||||
*
|
*
|
||||||
* Returns two elements array array containing the objects in
|
* Returns a two element array containing the objects in
|
||||||
* <i>enum</i> that gives the minimum and maximum values respectively
|
* <i>enum</i> that correspond to the minimum and maximum values respectively
|
||||||
* from the given block.
|
* from the given block.
|
||||||
*
|
*
|
||||||
* If no block is given, an enumerator is returned instead.
|
* If no block is given, an enumerator is returned instead.
|
||||||
|
@ -1762,7 +1760,6 @@ each_slice_i(VALUE i, VALUE *memo, int argc, VALUE *argv)
|
||||||
* Iterates the given block for each slice of <n> elements. If no
|
* Iterates the given block for each slice of <n> elements. If no
|
||||||
* block is given, returns an enumerator.
|
* block is given, returns an enumerator.
|
||||||
*
|
*
|
||||||
* e.g.:
|
|
||||||
* (1..10).each_slice(3) {|a| p a}
|
* (1..10).each_slice(3) {|a| p a}
|
||||||
* # outputs below
|
* # outputs below
|
||||||
* [1, 2, 3]
|
* [1, 2, 3]
|
||||||
|
@ -1862,7 +1859,6 @@ each_with_object_i(VALUE i, VALUE memo, int argc, VALUE *argv)
|
||||||
*
|
*
|
||||||
* If no block is given, returns an enumerator.
|
* If no block is given, returns an enumerator.
|
||||||
*
|
*
|
||||||
* e.g.:
|
|
||||||
* evens = (1..10).each_with_object([]) {|i, a| a << i*2 }
|
* evens = (1..10).each_with_object([]) {|i, a| a << i*2 }
|
||||||
* #=> [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]
|
* #=> [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]
|
||||||
*
|
*
|
||||||
|
|
Loading…
Add table
Reference in a new issue