Project

General

Profile

Misc #16126 ยป docs-bugs.patch

zverok (Victor Shepelev), 08/24/2019 05:35 PM

View differences:

enumerator.c
26 26
 * A class which allows both internal and external iteration.
27 27
 *
28 28
 * An Enumerator can be created by the following methods.
29
 * - Kernel#to_enum
30
 * - Kernel#enum_for
29
 * - Object#to_enum
30
 * - Object#enum_for
31 31
 * - Enumerator.new
32 32
 *
33 33
 * Most methods have two forms: a block form where the contents
......
417 417
 * In the second, deprecated, form, a generated Enumerator iterates over the
418 418
 * given object using the given method with the given arguments passed.
419 419
 *
420
 * Use of this form is discouraged.  Use Kernel#enum_for or Kernel#to_enum
420
 * Use of this form is discouraged.  Use Object#enum_for or Object#to_enum
421 421
 * instead.
422 422
 *
423 423
 *   e = Enumerator.new(ObjectSpace, :each_object)
......
1862 1862
 *
1863 1863
 * For example, continuing from the example in Object#to_enum:
1864 1864
 *
1865
 *   # See Kernel#to_enum for the definition of repeat
1865
 *   # See Object#to_enum for the definition of repeat
1866 1866
 *   r = 1..Float::INFINITY
1867 1867
 *   r.repeat(2).first(5) # => [1, 1, 2, 2, 3]
1868 1868
 *   r.repeat(2).class # => Enumerator
error.c
300 300

  
301 301
/*
302 302
 * call-seq:
303
 *    warn(msg, ...)   -> nil
303
 *    warn(*msgs, uplevel: nil)   -> nil
304 304
 *
305 305
 * If warnings have been disabled (for example with the
306 306
 * <code>-W0</code> flag), does nothing.  Otherwise,
......
2446 2446
 *    * IndexError
2447 2447
 *      * KeyError
2448 2448
 *      * StopIteration
2449
 *        * ClosedQueueError
2449 2450
 *    * LocalJumpError
2450 2451
 *    * NameError
2451 2452
 *      * NoMethodError
object.c
572 572
 *     3.next.then {|x| x**x }.to_s             #=> "256"
573 573
 *     "my string".yield_self {|s| s.upcase }   #=> "MY STRING"
574 574
 *
575
 *  Good usage for +yield_self+ is value piping in method chains:
575
 *  Good usage for +then+ is value piping in method chains:
576 576
 *
577 577
 *     require 'open-uri'
578 578
 *     require 'json'
579 579
 *
580 580
 *     construct_url(arguments).
581
 *       yield_self {|url| open(url).read }.
582
 *       yield_self {|response| JSON.parse(response) }
581
 *       then {|url| open(url).read }.
582
 *       then {|response| JSON.parse(response) }
583 583
 *
584 584
 *  When called without block, the method returns +Enumerator+,
585 585
 *  which can be used, for example, for conditional
586 586
 *  circuit-breaking:
587 587
 *
588 588
 *     # meets condition, no-op
589
 *     1.yield_self.detect(&:odd?)            # => 1
589
 *     1.then.detect(&:odd?)            # => 1
590 590
 *     # does not meet condition, drop value
591
 *     2.yield_self.detect(&:odd?)            # => nil
591
 *     2.then.detect(&:odd?)            # => nil
592 592
 *
593 593
 */
594 594