From 7c37f2cb1ad248a1db327f3522a8e3ffa5c5412f Mon Sep 17 00:00:00 2001 From: Marcus Stollsteimer Date: Sun, 22 Dec 2019 19:46:24 +0100 Subject: Some fixes in Enumerator::Lazy docs * fix list in #flat_map * fix wrong indentation in #filter_map and #with_index * other small fixes --- enumerator.c | 47 ++++++++++++++++++++++++----------------------- 1 file changed, 24 insertions(+), 23 deletions(-) (limited to 'enumerator.c') diff --git a/enumerator.c b/enumerator.c index 73bca61df2..0aa395a8ba 100644 --- a/enumerator.c +++ b/enumerator.c @@ -1736,7 +1736,7 @@ lazy_generator_init(VALUE enumerator, VALUE procs) /* * call-seq: - * Lazy.new(obj, size=nil) { |yielder, *values| ... } + * Lazy.new(obj, size=nil) { |yielder, *values| block } * * Creates a new Lazy enumerator. When the enumerator is actually enumerated * (e.g. by calling #force), +obj+ will be enumerated and each value passed @@ -1899,10 +1899,10 @@ lazy_to_enum_i(VALUE obj, VALUE meth, int argc, const VALUE *argv, rb_enumerator /* * call-seq: - * lzy.to_enum(method = :each, *args) -> lazy_enum - * lzy.enum_for(method = :each, *args) -> lazy_enum - * lzy.to_enum(method = :each, *args) {|*args| block} -> lazy_enum - * lzy.enum_for(method = :each, *args){|*args| block} -> lazy_enum + * lzy.to_enum(method = :each, *args) -> lazy_enum + * lzy.enum_for(method = :each, *args) -> lazy_enum + * lzy.to_enum(method = :each, *args) {|*args| block } -> lazy_enum + * lzy.enum_for(method = :each, *args) {|*args| block } -> lazy_enum * * Similar to Object#to_enum, except it returns a lazy enumerator. * This makes it easy to define Enumerable methods that will @@ -2080,19 +2080,19 @@ lazy_flat_map_proc(RB_BLOCK_CALL_FUNC_ARGLIST(val, m)) * lazy.flat_map { |obj| block } -> a_lazy_enumerator * * Returns a new lazy enumerator with the concatenated results of running - * block once for every element in lazy. + * +block+ once for every element in the lazy enumerator. * * ["foo", "bar"].lazy.flat_map {|i| i.each_char.lazy}.force * #=> ["f", "o", "o", "b", "a", "r"] * - * A value x returned by block is decomposed if either of + * A value +x+ returned by +block+ is decomposed if either of * the following conditions is true: * - * * a) x responds to both each and force, which means that - * x is a lazy enumerator. - * * b) x is an array or responds to to_ary. + * * +x+ responds to both each and force, which means that + * +x+ is a lazy enumerator. + * * +x+ is an array or responds to to_ary. * - * Otherwise, x is contained as-is in the return value. + * Otherwise, +x+ is contained as-is in the return value. * * [{a:1}, {b:2}].lazy.flat_map {|i| i}.force * #=> [{:a=>1}, {:b=>2}] @@ -2159,7 +2159,8 @@ static const lazyenum_funcs lazy_filter_map_funcs = { * * Like Enumerable#filter_map, but chains operation to be lazy-evaluated. * - * (1..).lazy.filter_map { |i| i * 2 if i.even? }.first(5) #=> [4, 8, 12, 16, 20] + * (1..).lazy.filter_map { |i| i * 2 if i.even? }.first(5) + * #=> [4, 8, 12, 16, 20] */ static VALUE @@ -2631,8 +2632,8 @@ static const lazyenum_funcs lazy_uniq_funcs = { /* * call-seq: - * lazy.uniq -> lazy_enumerator - * lazy.uniq { |item| ... } -> lazy_enumerator + * lazy.uniq -> lazy_enumerator + * lazy.uniq { |item| block } -> lazy_enumerator * * Like Enumerable#uniq, but chains operation to be lazy-evaluated. */ @@ -2674,20 +2675,20 @@ static const lazyenum_funcs lazy_with_index_funcs = { }; /* - * call-seq: - * lazy.with_index(offset = 0) {|(*args), idx| ... } - * lazy.with_index(offset = 0) + * call-seq: + * lazy.with_index(offset = 0) {|(*args), idx| block } + * lazy.with_index(offset = 0) * - * If a block is given, iterates the given block for each element - * with an index, which starts from +offset+, and returns a - * lazy enumerator that yields the same values (without the index). + * If a block is given, iterates the given block for each element + * with an index, which starts from +offset+, and returns a + * lazy enumerator that yields the same values (without the index). * - * If a block is not given, returns a new lazy enumerator that - * includes the index, starting from +offset+. + * If a block is not given, returns a new lazy enumerator that + * includes the index, starting from +offset+. * * +offset+:: the starting index to use * - * see Enumerator#with_index. + * See Enumerator#with_index. */ static VALUE lazy_with_index(int argc, VALUE *argv, VALUE obj) -- cgit v1.2.3