summaryrefslogtreecommitdiff
path: root/enum.c
diff options
context:
space:
mode:
authordrbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-10-06 00:57:06 +0000
committerdrbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-10-06 00:57:06 +0000
commite2974b1a4b3263c8c66581f6e3943c193b1e2d3b (patch)
tree247ad882e324c185f8b3d8aa46e10c68aeb800c4 /enum.c
parent9edfa89744eae3aa286f6bb746fe16fdc6dd42af (diff)
* 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
Diffstat (limited to 'enum.c')
-rw-r--r--enum.c34
1 files changed, 15 insertions, 19 deletions
diff --git a/enum.c b/enum.c
index 77ecd2fa56..3120b066da 100644
--- a/enum.c
+++ b/enum.c
@@ -129,11 +129,11 @@ count_all_i(VALUE i, VALUE memop, int argc, VALUE *argv)
* enum.count(item) -> int
* enum.count {| obj | block } -> int
*
- * Returns the number of items in <i>enum</i>, where #size is called
- * if it responds to it, otherwise the items are counted through
- * enumeration. If an argument is given, counts the number of items
- * in <i>enum</i>, for which equals to <i>item</i>. If a block is
- * given, counts the number of elements yielding a true value.
+ * Returns the number of items in <i>enum</i> if it responds to a #size call,
+ * otherwise the items are counted through enumeration. If an argument is
+ * given the number of items in <i>enum</i> that are equal to <i>item</i> are
+ * counted. If a block is given, it counts the number of elements yielding a
+ * true value.
*
* ary = [1, 2, 4, 2]
* ary.count #=> 4
@@ -539,10 +539,9 @@ inject_op_i(VALUE i, VALUE p, int argc, VALUE *argv)
* return value for the method.
*
* 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>.
*
- * Examples:
*
* # Sum some numbers
* (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
* array of tuples containing the original collection element and the
* mapped value. This makes <code>sort_by</code> fairly expensive when
- * the keysets are simple
+ * the keysets are simple.
*
* require 'benchmark'
*
@@ -970,9 +969,9 @@ DEFINE_ENUMFUNCS(all)
* Passes each element of the collection to the given block. The method
* returns <code>true</code> if the block never returns
* <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
- * <code>all?</code> will return <code>true</code> only if none of the
- * collection members are <code>false</code> or <code>nil</code>.)
+ * Ruby adds an implicit block of <code>{ |obj| obj }</code> which will
+ * cause #all? to return +true+ when none of the collection members are
+ * +false+ or +nil+.
*
* %w{ant bear cat}.all? {|word| word.length >= 3} #=> true
* %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
* 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
- * 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
- * of the collection members is not <code>false</code> or
- * <code>nil</code>.
+ * given, Ruby adds an implicit block of <code>{ |obj| obj }</code> that
+ * will cause #any? to return +true+ if at least one of the collection
+ * members is not +false+ or +nil+.
*
* %w{ant bear cat}.any? {|word| word.length >= 3} #=> 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 -> an_enumerator
*
- * Returns two elements array array containing the objects in
- * <i>enum</i> that gives the minimum and maximum values respectively
+ * Returns a two element array containing the objects in
+ * <i>enum</i> that correspond to the minimum and maximum values respectively
* from the given block.
*
* 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
* block is given, returns an enumerator.
*
- * e.g.:
* (1..10).each_slice(3) {|a| p a}
* # outputs below
* [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.
*
- * e.g.:
* evens = (1..10).each_with_object([]) {|i, a| a << i*2 }
* #=> [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]
*