summaryrefslogtreecommitdiff
path: root/enum.c
diff options
context:
space:
mode:
authorBurdette Lamar <[email protected]>2021-09-10 17:21:21 -0500
committer<[email protected]>2021-09-10 17:21:21 -0500
commit967b9743faac0b55a3d8deb176a08fdff449bba8 ()
treeea435619ace589f43b3ed524226b3883eb590f37 /enum.c
parentc09f8e56bc28227aaa1c00d1d6d93e69b322fb41 (diff)
Enhanced RDoc for Enumerable (#4808)
#to_a #to_h #inject
Notes: Merged-By: BurdetteLamar <[email protected]>
-rw-r--r--enum.c47
1 files changed, 21 insertions, 26 deletions
@@ -700,16 +700,13 @@ enum_flat_map(VALUE obj)
/*
* call-seq:
- * enum.to_a(*args) -> array
- * enum.entries(*args) -> array
*
- * Returns an array containing the items in <i>enum</i>.
*
- * (1..7).to_a #=> [1, 2, 3, 4, 5, 6, 7]
- * { 'a'=>1, 'b'=>2, 'c'=>3 }.to_a #=> [["a", 1], ["b", 2], ["c", 3]]
*
- * require 'prime'
- * Prime.entries 10 #=> [2, 3, 5, 7]
*/
static VALUE
enum_to_a(int argc, VALUE *argv, VALUE obj)
@@ -749,20 +746,23 @@ enum_to_h_ii(RB_BLOCK_CALL_FUNC_ARGLIST(i, hash))
/*
* call-seq:
- * enum.to_h(*args) -> hash
- * enum.to_h(*args) {...} -> hash
*
- * Returns the result of interpreting <i>enum</i> as a list of
- * <tt>[key, value]</tt> pairs.
*
- * %i[hello world].each_with_index.to_h
- * # => {:hello => 0, :world => 1}
*
- * If a block is given, the results of the block on each element of
- * the enum will be used as pairs.
*
- * (1..5).to_h {|x| [x, x ** 2]}
- * #=> {1=>1, 2=>4, 3=>9, 4=>16, 5=>25}
*/
static VALUE
@@ -871,14 +871,10 @@ ary_inject_op(VALUE ary, VALUE init, VALUE op)
/*
* call-seq:
- * enum.inject(initial, sym) -> obj
- * enum.inject(sym) -> obj
- * enum.inject(initial) { |memo, obj| block } -> obj
- * enum.inject { |memo, obj| block } -> obj
- * enum.reduce(initial, sym) -> obj
- * enum.reduce(sym) -> obj
- * enum.reduce(initial) { |memo, obj| block } -> obj
- * enum.reduce { |memo, obj| block } -> obj
*
* Combines all elements of <i>enum</i> by applying a binary
* operation, specified by a block or a symbol that names a
@@ -913,7 +909,6 @@ ary_inject_op(VALUE ary, VALUE init, VALUE op)
* memo.length > word.length ? memo : word
* end
* longest #=> "sheep"
- *
*/
static VALUE
enum_inject(int argc, VALUE *argv, VALUE obj)