Skip to content

Commit

Permalink
[DOC] Fix indentation for Numeric#step
Browse files Browse the repository at this point in the history
The documentation was indented one level too deep, which causes RDoc to
generate it all as a code block.
  • Loading branch information
peterzhu2118 committed Dec 29, 2023
1 parent 5fd1738 commit 606c017
Showing 1 changed file with 69 additions and 69 deletions.
138 changes: 69 additions & 69 deletions numeric.c
Expand Up @@ -2946,88 +2946,88 @@ num_step_size(VALUE from, VALUE args, VALUE eobj)
* step(by: , to: nil) {|n| ... } -> self
* step(by: , to: nil) -> enumerator
*
* Generates a sequence of numbers; with a block given, traverses the sequence.
* Generates a sequence of numbers; with a block given, traverses the sequence.
*
* Of the Core and Standard Library classes,
* Integer, Float, and Rational use this implementation.
* Of the Core and Standard Library classes,
* Integer, Float, and Rational use this implementation.
*
* A quick example:
* A quick example:
*
* squares = []
* 1.step(by: 2, to: 10) {|i| squares.push(i*i) }
* squares # => [1, 9, 25, 49, 81]
* squares = []
* 1.step(by: 2, to: 10) {|i| squares.push(i*i) }
* squares # => [1, 9, 25, 49, 81]
*
* The generated sequence:
* The generated sequence:
*
* - Begins with +self+.
* - Continues at intervals of +by+ (which may not be zero).
* - Ends with the last number that is within or equal to +to+;
* that is, less than or equal to +to+ if +by+ is positive,
* greater than or equal to +to+ if +by+ is negative.
* If +to+ is +nil+, the sequence is of infinite length.
* - Begins with +self+.
* - Continues at intervals of +by+ (which may not be zero).
* - Ends with the last number that is within or equal to +to+;
* that is, less than or equal to +to+ if +by+ is positive,
* greater than or equal to +to+ if +by+ is negative.
* If +to+ is +nil+, the sequence is of infinite length.
*
* If a block is given, calls the block with each number in the sequence;
* returns +self+. If no block is given, returns an Enumerator::ArithmeticSequence.
*
* <b>Keyword Arguments</b>
*
* With keyword arguments +by+ and +to+,
* their values (or defaults) determine the step and limit:
*
* # Both keywords given.
* squares = []
* 4.step(by: 2, to: 10) {|i| squares.push(i*i) } # => 4
* squares # => [16, 36, 64, 100]
* cubes = []
* 3.step(by: -1.5, to: -3) {|i| cubes.push(i*i*i) } # => 3
* cubes # => [27.0, 3.375, 0.0, -3.375, -27.0]
* squares = []
* 1.2.step(by: 0.2, to: 2.0) {|f| squares.push(f*f) }
* squares # => [1.44, 1.9599999999999997, 2.5600000000000005, 3.24, 4.0]
*
* squares = []
* Rational(6/5).step(by: 0.2, to: 2.0) {|r| squares.push(r*r) }
* squares # => [1.0, 1.44, 1.9599999999999997, 2.5600000000000005, 3.24, 4.0]
*
* # Only keyword to given.
* squares = []
* 4.step(to: 10) {|i| squares.push(i*i) } # => 4
* squares # => [16, 25, 36, 49, 64, 81, 100]
* # Only by given.
*
* # Only keyword by given
* squares = []
* 4.step(by:2) {|i| squares.push(i*i); break if i > 10 }
* squares # => [16, 36, 64, 100, 144]
*
* # No block given.
* e = 3.step(by: -1.5, to: -3) # => (3.step(by: -1.5, to: -3))
* e.class # => Enumerator::ArithmeticSequence
*
* <b>Positional Arguments</b>
*
* With optional positional arguments +to+ and +by+,
* their values (or defaults) determine the step and limit:
*
* squares = []
* 4.step(10, 2) {|i| squares.push(i*i) } # => 4
* squares # => [16, 36, 64, 100]
* squares = []
* 4.step(10) {|i| squares.push(i*i) }
* squares # => [16, 25, 36, 49, 64, 81, 100]
* squares = []
* 4.step {|i| squares.push(i*i); break if i > 10 } # => nil
* squares # => [16, 25, 36, 49, 64, 81, 100, 121]
* <b>Keyword Arguments</b>
*
* With keyword arguments +by+ and +to+,
* their values (or defaults) determine the step and limit:
*
* # Both keywords given.
* squares = []
* 4.step(by: 2, to: 10) {|i| squares.push(i*i) } # => 4
* squares # => [16, 36, 64, 100]
* cubes = []
* 3.step(by: -1.5, to: -3) {|i| cubes.push(i*i*i) } # => 3
* cubes # => [27.0, 3.375, 0.0, -3.375, -27.0]
* squares = []
* 1.2.step(by: 0.2, to: 2.0) {|f| squares.push(f*f) }
* squares # => [1.44, 1.9599999999999997, 2.5600000000000005, 3.24, 4.0]
*
* squares = []
* Rational(6/5).step(by: 0.2, to: 2.0) {|r| squares.push(r*r) }
* squares # => [1.0, 1.44, 1.9599999999999997, 2.5600000000000005, 3.24, 4.0]
*
* # Only keyword to given.
* squares = []
* 4.step(to: 10) {|i| squares.push(i*i) } # => 4
* squares # => [16, 25, 36, 49, 64, 81, 100]
* # Only by given.
*
* # Only keyword by given
* squares = []
* 4.step(by:2) {|i| squares.push(i*i); break if i > 10 }
* squares # => [16, 36, 64, 100, 144]
*
* # No block given.
* e = 3.step(by: -1.5, to: -3) # => (3.step(by: -1.5, to: -3))
* e.class # => Enumerator::ArithmeticSequence
*
* <b>Positional Arguments</b>
*
* With optional positional arguments +to+ and +by+,
* their values (or defaults) determine the step and limit:
*
* squares = []
* 4.step(10, 2) {|i| squares.push(i*i) } # => 4
* squares # => [16, 36, 64, 100]
* squares = []
* 4.step(10) {|i| squares.push(i*i) }
* squares # => [16, 25, 36, 49, 64, 81, 100]
* squares = []
* 4.step {|i| squares.push(i*i); break if i > 10 } # => nil
* squares # => [16, 25, 36, 49, 64, 81, 100, 121]
*
* <b>Implementation Notes</b>
*
* If all the arguments are integers, the loop operates using an integer
* counter.
* If all the arguments are integers, the loop operates using an integer
* counter.
*
* If any of the arguments are floating point numbers, all are converted
* to floats, and the loop is executed
* <i>floor(n + n*Float::EPSILON) + 1</i> times,
* where <i>n = (limit - self)/step</i>.
* If any of the arguments are floating point numbers, all are converted
* to floats, and the loop is executed
* <i>floor(n + n*Float::EPSILON) + 1</i> times,
* where <i>n = (limit - self)/step</i>.
*
*/

Expand Down

0 comments on commit 606c017

Please sign in to comment.