Project

General

Profile

Actions

Bug #17092

closed

Array#flatten with finite depth should flatten recursive arrays

Added by marcandre (Marc-Andre Lafortune) over 3 years ago. Updated about 3 years ago.

Status:
Closed
Assignee:
-
Target version:
-
[ruby-core:99399]

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.

Actions #1

Updated by Anonymous over 3 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]

Actions #2

Updated by nagachika (Tomoyuki Chikanaga) about 3 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

Also available in: Atom PDF

Like0
Like0Like0