Skip to content

Commit cfa50b0

Browse files
sourya2704nobu
authored andcommitted
[DOC] Fix outdated results in examples
Some example results in the docs no longer match what Ruby prints: * Array#flatten and Array#flatten!: Set#inspect now shows Set[6, 7] * Module: Mod.constants also includes Math::DomainError * Module#const_get and Module#const_set: Floats are shown with full precision * Complex#imag: sin(PI/4) is 0.7071067811865475 * String#<<: missing # in #<Encoding:UTF-8> * Enumerable#inject: typo #=>>
1 parent 536dc6f commit cfa50b0

5 files changed

Lines changed: 22 additions & 22 deletions

File tree

‎array.c‎

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6851,16 +6851,16 @@ single_nested_array(VALUE ary)
68516851
* With non-negative integer argument +depth+, flattens recursively through +depth+ levels:
68526852
*
68536853
* a = [ 0, [ 1, [2, 3], 4 ], 5, {foo: 0}, Set.new([6, 7]) ]
6854-
* a # => [0, [1, [2, 3], 4], 5, {foo: 0}, #<Set: {6, 7}>]
6855-
* a.dup.flatten!(1) # => [0, 1, [2, 3], 4, 5, {foo: 0}, #<Set: {6, 7}>]
6856-
* a.dup.flatten!(1.1) # => [0, 1, [2, 3], 4, 5, {foo: 0}, #<Set: {6, 7}>]
6857-
* a.dup.flatten!(2) # => [0, 1, 2, 3, 4, 5, {foo: 0}, #<Set: {6, 7}>]
6858-
* a.dup.flatten!(3) # => [0, 1, 2, 3, 4, 5, {foo: 0}, #<Set: {6, 7}>]
6854+
* a # => [0, [1, [2, 3], 4], 5, {foo: 0}, Set[6, 7]]
6855+
* a.dup.flatten!(1) # => [0, 1, [2, 3], 4, 5, {foo: 0}, Set[6, 7]]
6856+
* a.dup.flatten!(1.1) # => [0, 1, [2, 3], 4, 5, {foo: 0}, Set[6, 7]]
6857+
* a.dup.flatten!(2) # => [0, 1, 2, 3, 4, 5, {foo: 0}, Set[6, 7]]
6858+
* a.dup.flatten!(3) # => [0, 1, 2, 3, 4, 5, {foo: 0}, Set[6, 7]]
68596859
*
68606860
* With +nil+ or negative argument +depth+, flattens all levels:
68616861
*
6862-
* a.dup.flatten! # => [0, 1, 2, 3, 4, 5, {foo: 0}, #<Set: {6, 7}>]
6863-
* a.dup.flatten!(-1) # => [0, 1, 2, 3, 4, 5, {foo: 0}, #<Set: {6, 7}>]
6862+
* a.dup.flatten! # => [0, 1, 2, 3, 4, 5, {foo: 0}, Set[6, 7]]
6863+
* a.dup.flatten!(-1) # => [0, 1, 2, 3, 4, 5, {foo: 0}, Set[6, 7]]
68646864
*
68656865
* Related: Array#flatten;
68666866
* see also {Methods for Assigning}[rdoc-ref:Array@Methods+for+Assigning].
@@ -6920,17 +6920,17 @@ rb_ary_flatten_bang(int argc, VALUE *argv, VALUE ary)
69206920
* With non-negative integer argument +depth+, flattens recursively through +depth+ levels:
69216921
*
69226922
* a = [ 0, [ 1, [2, 3], 4 ], 5, {foo: 0}, Set.new([6, 7]) ]
6923-
* a # => [0, [1, [2, 3], 4], 5, {foo: 0}, #<Set: {6, 7}>]
6924-
* a.flatten(0) # => [0, [1, [2, 3], 4], 5, {foo: 0}, #<Set: {6, 7}>]
6925-
* a.flatten(1 ) # => [0, 1, [2, 3], 4, 5, {foo: 0}, #<Set: {6, 7}>]
6926-
* a.flatten(1.1) # => [0, 1, [2, 3], 4, 5, {foo: 0}, #<Set: {6, 7}>]
6927-
* a.flatten(2) # => [0, 1, 2, 3, 4, 5, {foo: 0}, #<Set: {6, 7}>]
6928-
* a.flatten(3) # => [0, 1, 2, 3, 4, 5, {foo: 0}, #<Set: {6, 7}>]
6923+
* a # => [0, [1, [2, 3], 4], 5, {foo: 0}, Set[6, 7]]
6924+
* a.flatten(0) # => [0, [1, [2, 3], 4], 5, {foo: 0}, Set[6, 7]]
6925+
* a.flatten(1 ) # => [0, 1, [2, 3], 4, 5, {foo: 0}, Set[6, 7]]
6926+
* a.flatten(1.1) # => [0, 1, [2, 3], 4, 5, {foo: 0}, Set[6, 7]]
6927+
* a.flatten(2) # => [0, 1, 2, 3, 4, 5, {foo: 0}, Set[6, 7]]
6928+
* a.flatten(3) # => [0, 1, 2, 3, 4, 5, {foo: 0}, Set[6, 7]]
69296929
*
69306930
* With +nil+ or negative +depth+, flattens all levels.
69316931
*
6932-
* a.flatten # => [0, 1, 2, 3, 4, 5, {foo: 0}, #<Set: {6, 7}>]
6933-
* a.flatten(-1) # => [0, 1, 2, 3, 4, 5, {foo: 0}, #<Set: {6, 7}>]
6932+
* a.flatten # => [0, 1, 2, 3, 4, 5, {foo: 0}, Set[6, 7]]
6933+
* a.flatten(-1) # => [0, 1, 2, 3, 4, 5, {foo: 0}, Set[6, 7]]
69346934
*
69356935
* Related: Array#flatten!;
69366936
* see also {Methods for Converting}[rdoc-ref:Array@Methods+for+Converting].

‎complex.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -762,7 +762,7 @@ rb_complex_real(VALUE self)
762762
* {polar coordinates}[rdoc-ref:Complex@Polar+Coordinates], the returned value
763763
* is computed, and may be inexact:
764764
*
765-
* Complex.polar(1, Math::PI/4).imag # => 0.7071067811865476 # Square root of 2.
765+
* Complex.polar(1, Math::PI/4).imag # => 0.7071067811865475
766766
*
767767
*/
768768
VALUE

‎enum.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1021,7 +1021,7 @@ ary_inject_op(VALUE ary, VALUE init, VALUE op)
10211021
* end
10221022
*
10231023
* position = "nnneesw".chars.reduce(Turtle.new, :move)
1024-
* position #=>> #<Turtle:0x00000001052f4698 @y=2, @x=1>
1024+
* position #=> #<Turtle:0x00000001052f4698 @y=2, @x=1>
10251025
*
10261026
* <b>Third Shortcut: Reducer With no Initial Value</b>
10271027
*

‎object.c‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1797,7 +1797,7 @@ rb_obj_cmp(VALUE obj1, VALUE obj2)
17971797
* end
17981798
* end
17991799
* Mod.class #=> Module
1800-
* Mod.constants #=> [:CONST, :PI, :E]
1800+
* Mod.constants #=> [:CONST, :DomainError, :PI, :E]
18011801
* Mod.instance_methods #=> [:meth]
18021802
*
18031803
*/
@@ -2611,7 +2611,7 @@ rb_mod_attr_accessor(int argc, VALUE *argv, VALUE klass)
26112611
* The value of the constant is returned if a definition is found,
26122612
* otherwise a +NameError+ is raised.
26132613
*
2614-
* Math.const_get(:PI) #=> 3.14159265358979
2614+
* Math.const_get(:PI) #=> 3.141592653589793
26152615
*
26162616
* This method will recursively look up constant names if a namespaced
26172617
* class name is provided. For example:
@@ -2751,8 +2751,8 @@ rb_mod_const_get(int argc, VALUE *argv, VALUE mod)
27512751
* Creates a new constant if no constant with the given name previously
27522752
* existed.
27532753
*
2754-
* Math.const_set("HIGH_SCHOOL_PI", 22.0/7.0) #=> 3.14285714285714
2755-
* Math::HIGH_SCHOOL_PI - Math::PI #=> 0.00126448926734968
2754+
* Math.const_set("HIGH_SCHOOL_PI", 22.0/7.0) #=> 3.142857142857143
2755+
* Math::HIGH_SCHOOL_PI - Math::PI #=> 0.0012644892673496777
27562756
*
27572757
* If +sym+ or +str+ is not a valid constant name a +NameError+ will be
27582758
* raised with a warning "wrong constant name".

‎string.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4149,7 +4149,7 @@ rb_str_append_as_bytes(int argc, VALUE *argv, VALUE str)
41494149
* Raises RangeError if that codepoint is not representable in the encoding of +self+:
41504150
*
41514151
* s = 'foo'
4152-
* s.encoding # => <Encoding:UTF-8>
4152+
* s.encoding # => #<Encoding:UTF-8>
41534153
* s << 0x00110000 # 1114112 out of char range (RangeError)
41544154
* s = 'foo'.encode(Encoding::EUC_JP)
41554155
* s << 0x00800080 # invalid codepoint 0x800080 in EUC-JP (RangeError)

0 commit comments

Comments
 (0)