mirror of
https://github.com/ruby/ruby.git
synced 2026-10-28 16:36:20 +08:00
[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 #=>>
This commit is contained in:
1 parent
536dc6f98b
commit
cfa50b0093
5 files changed
+22
-22
Notes:
git
2026-10-21 08:53:01 +00:00
No files matched your search
@@ -6851,16 +6851,16 @@ single_nested_array(VALUE ary)
|
||||
* With non-negative integer argument +depth+, flattens recursively through +depth+ levels:
|
||||
*
|
||||
* a = [ 0, [ 1, [2, 3], 4 ], 5, {foo: 0}, Set.new([6, 7]) ]
|
||||
* a # => [0, [1, [2, 3], 4], 5, {foo: 0}, #<Set: {6, 7}>]
|
||||
* a.dup.flatten!(1) # => [0, 1, [2, 3], 4, 5, {foo: 0}, #<Set: {6, 7}>]
|
||||
* a.dup.flatten!(1.1) # => [0, 1, [2, 3], 4, 5, {foo: 0}, #<Set: {6, 7}>]
|
||||
* a.dup.flatten!(2) # => [0, 1, 2, 3, 4, 5, {foo: 0}, #<Set: {6, 7}>]
|
||||
* a.dup.flatten!(3) # => [0, 1, 2, 3, 4, 5, {foo: 0}, #<Set: {6, 7}>]
|
||||
* a # => [0, [1, [2, 3], 4], 5, {foo: 0}, Set[6, 7]]
|
||||
* a.dup.flatten!(1) # => [0, 1, [2, 3], 4, 5, {foo: 0}, Set[6, 7]]
|
||||
* a.dup.flatten!(1.1) # => [0, 1, [2, 3], 4, 5, {foo: 0}, Set[6, 7]]
|
||||
* a.dup.flatten!(2) # => [0, 1, 2, 3, 4, 5, {foo: 0}, Set[6, 7]]
|
||||
* a.dup.flatten!(3) # => [0, 1, 2, 3, 4, 5, {foo: 0}, Set[6, 7]]
|
||||
*
|
||||
* With +nil+ or negative argument +depth+, flattens all levels:
|
||||
*
|
||||
* a.dup.flatten! # => [0, 1, 2, 3, 4, 5, {foo: 0}, #<Set: {6, 7}>]
|
||||
* a.dup.flatten!(-1) # => [0, 1, 2, 3, 4, 5, {foo: 0}, #<Set: {6, 7}>]
|
||||
* a.dup.flatten! # => [0, 1, 2, 3, 4, 5, {foo: 0}, Set[6, 7]]
|
||||
* a.dup.flatten!(-1) # => [0, 1, 2, 3, 4, 5, {foo: 0}, Set[6, 7]]
|
||||
*
|
||||
* Related: Array#flatten;
|
||||
* 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)
|
||||
* With non-negative integer argument +depth+, flattens recursively through +depth+ levels:
|
||||
*
|
||||
* a = [ 0, [ 1, [2, 3], 4 ], 5, {foo: 0}, Set.new([6, 7]) ]
|
||||
* a # => [0, [1, [2, 3], 4], 5, {foo: 0}, #<Set: {6, 7}>]
|
||||
* a.flatten(0) # => [0, [1, [2, 3], 4], 5, {foo: 0}, #<Set: {6, 7}>]
|
||||
* a.flatten(1 ) # => [0, 1, [2, 3], 4, 5, {foo: 0}, #<Set: {6, 7}>]
|
||||
* a.flatten(1.1) # => [0, 1, [2, 3], 4, 5, {foo: 0}, #<Set: {6, 7}>]
|
||||
* a.flatten(2) # => [0, 1, 2, 3, 4, 5, {foo: 0}, #<Set: {6, 7}>]
|
||||
* a.flatten(3) # => [0, 1, 2, 3, 4, 5, {foo: 0}, #<Set: {6, 7}>]
|
||||
* a # => [0, [1, [2, 3], 4], 5, {foo: 0}, Set[6, 7]]
|
||||
* a.flatten(0) # => [0, [1, [2, 3], 4], 5, {foo: 0}, Set[6, 7]]
|
||||
* a.flatten(1 ) # => [0, 1, [2, 3], 4, 5, {foo: 0}, Set[6, 7]]
|
||||
* a.flatten(1.1) # => [0, 1, [2, 3], 4, 5, {foo: 0}, Set[6, 7]]
|
||||
* a.flatten(2) # => [0, 1, 2, 3, 4, 5, {foo: 0}, Set[6, 7]]
|
||||
* a.flatten(3) # => [0, 1, 2, 3, 4, 5, {foo: 0}, Set[6, 7]]
|
||||
*
|
||||
* With +nil+ or negative +depth+, flattens all levels.
|
||||
*
|
||||
* a.flatten # => [0, 1, 2, 3, 4, 5, {foo: 0}, #<Set: {6, 7}>]
|
||||
* a.flatten(-1) # => [0, 1, 2, 3, 4, 5, {foo: 0}, #<Set: {6, 7}>]
|
||||
* a.flatten # => [0, 1, 2, 3, 4, 5, {foo: 0}, Set[6, 7]]
|
||||
* a.flatten(-1) # => [0, 1, 2, 3, 4, 5, {foo: 0}, Set[6, 7]]
|
||||
*
|
||||
* Related: Array#flatten!;
|
||||
* see also {Methods for Converting}[rdoc-ref:Array@Methods+for+Converting].
|
||||
|
||||
Reference in new issue
Block a user