Actions
Bug #17092
closedArray#flatten with finite depth should flatten recursive arrays
Description
Recursive arrays can not be flattened currently:
a = []; a << a
a.flatten(2) # => tried to flatten recursive array
The only valid reason to raise an error for recursive arrays is for flatten with no argument (or negative argument); the case for finite-depth flatten is not problematic.
This fix has the bonus of speeding up the finite-depth case in general.
I will merge https://github.com/ruby/ruby/pull/3374, @nobu (Nobuyoshi Nakada) asked for backports.
Updated by Anonymous over 4 years ago
- Status changed from Open to Closed
Applied in changeset git|1b1ea7b3bc9484e6e59d716fce2965a2f39d1e3d.
Fix Array#flatten for recursive array when given positive depth [Bug #17092]
Updated by nagachika (Tomoyuki Chikanaga) almost 4 years ago
- Backport changed from 2.5: UNKNOWN, 2.6: UNKNOWN, 2.7: REQUIRED to 2.5: UNKNOWN, 2.6: UNKNOWN, 2.7: DONE
ruby_2_7 69d01653f831052acdc803aad0b78690ad61ca86 merged revision(s) 1b1ea7b3bc9484e6e59d716fce2965a2f39d1e3d,b6e6807993c770c5d2e069d8741f5dadf0b38069.
Actions
Like0
Like0Like0